<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge" >
  <link rel="dns-prefetch" href="https://marscarm.gitee.io">
  <title>Mysql数据库 | Marscarm的博客</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="摘要：本篇blog讲解Mysql数据库">
<meta property="og:type" content="article">
<meta property="og:title" content="Mysql数据库">
<meta property="og:url" content="https://marscarm.gitee.io/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/index.html">
<meta property="og:site_name" content="Marscarm的博客">
<meta property="og:description" content="摘要：本篇blog讲解Mysql数据库">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="https://marscarm.gitee.io/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/4717673e36966e0e4b33fccfd753f6ea.png">
<meta property="og:image" content="https://marscarm.gitee.io/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/5897753dfb301dfa3a814ab06e718a5e.png">
<meta property="og:image" content="https://marscarm.gitee.io/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/image-20211118211243137.png">
<meta property="og:image" content="https://marscarm.gitee.io/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/image-20211118211350563.png">
<meta property="og:image" content="https://marscarm.gitee.io/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/image-20211118211526594.png">
<meta property="og:image" content="https://marscarm.gitee.io/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/image-20211118211544382.png">
<meta property="og:image" content="https://marscarm.gitee.io/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/image-20211119084423716.png">
<meta property="og:image" content="https://marscarm.gitee.io/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/image-20211119084812153.png">
<meta property="og:image" content="https://marscarm.gitee.io/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/13526879-3037b144ed09eb88.png">
<meta property="og:image" content="https://marscarm.gitee.io/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/1415873-20190605112809343-999138139.png">
<meta property="og:image" content="https://marscarm.gitee.io/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/1415873-20190605112833419-1781156622.png">
<meta property="og:image" content="https://marscarm.gitee.io/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/463931-20170331230304992-1130032942.png">
<meta property="article:published_time" content="2021-11-08T09:27:00.000Z">
<meta property="article:modified_time" content="2022-03-24T08:06:12.412Z">
<meta property="article:author" content="marscarm">
<meta property="article:tag" content="数据库">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://marscarm.gitee.io/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/4717673e36966e0e4b33fccfd753f6ea.png">
  
    <link rel="alternative" href="/atom.xml" title="Marscarm的博客" type="application/atom+xml">
  
  
    <!-- <link rel="icon" href="/favicon.png"> -->
    <link rel="icon" href="/img/favicon.ico">
  
  <link rel="stylesheet" type="text/css" href="/./main.0cf68a.css">
  <style type="text/css">
  
    #container.show {
      background: linear-gradient(200deg,#a0cfe4,#e8c37e);
    }
  </style>
  

  

<meta name="generator" content="Hexo 5.4.0"></head>

<body>
  <div id="container" q-class="show:isCtnShow">
    <canvas id="anm-canvas" class="anm-canvas"></canvas>
    <div class="left-col" q-class="show:isShow">
      
<div class="overlay" style="background: #4d4d4d"></div>
<div class="intrude-less">
	<header id="header" class="inner">
		<a href="/" class="profilepic">
			<img src="/assets/img/headPortrait.jpg" class="js-avatar">
		</a>
		<hgroup>
		  <h1 class="header-author"><a href="/">Marscarm</a></h1>
		</hgroup>
		
		<p class="header-subtitle">孤独转码路......</p>
		

		<nav class="header-menu">
			<ul>
			
				<li><a href="/">主页</a></li>
	        
				<li><a href="/tags/%E9%9A%8F%E7%AC%94/">随笔</a></li>
	        
				<li><a href="/archives/index.html">归档</a></li>
	        
			</ul>
		</nav>
		<nav class="header-smart-menu">
    		
    			
    			<a q-on="click: openSlider(e, 'innerArchive')" href="javascript:void(0)">所有文章</a>
    			
            
    			
    			<a q-on="click: openSlider(e, 'aboutme')" href="javascript:void(0)">关于我</a>
    			
            
		</nav>
		<nav class="header-nav">
			<div class="social">
				
					<a class="github" target="_blank" href="https://github.com/Marscarm" title="github"><i class="icon-github"></i></a>
		        
					<a class="zhihu" target="_blank" href="https://www.zhihu.com/people/huo-xing-ren-50-51-8" title="zhihu"><i class="icon-zhihu"></i></a>
		        
			</div>
			<!-- 网易云音乐插件 -->
			

		</nav>
	</header>		
</div>

    </div>
    <div class="mid-col" q-class="show:isShow,hide:isShow|isFalse">
      
<nav id="mobile-nav">
  	<div class="overlay js-overlay" style="background: #4d4d4d"></div>
	<div class="btnctn js-mobile-btnctn">
  		<div class="slider-trigger list" q-on="click: openSlider(e)"><i class="icon icon-sort"></i></div>
	</div>
	<div class="intrude-less">
		<header id="header" class="inner">
			<div class="profilepic">
				<img src="/assets/img/headPortrait.jpg" class="js-avatar">
			</div>
			<hgroup>
			  <h1 class="header-author js-header-author">Marscarm</h1>
			</hgroup>
			
			<p class="header-subtitle"><i class="icon icon-quo-left"></i>孤独转码路......<i class="icon icon-quo-right"></i></p>
			
			
			
				
			
				
			
				
			
			
			
			<nav class="header-nav">
				<div class="social">
					
						<a class="github" target="_blank" href="https://github.com/Marscarm" title="github"><i class="icon-github"></i></a>
			        
						<a class="zhihu" target="_blank" href="https://www.zhihu.com/people/huo-xing-ren-50-51-8" title="zhihu"><i class="icon-zhihu"></i></a>
			        
				</div>
			</nav>

			<nav class="header-menu js-header-menu">
				<ul style="width: 70%">
				
				
					<li style="width: 33.333333333333336%"><a href="/">主页</a></li>
		        
					<li style="width: 33.333333333333336%"><a href="/tags/%E9%9A%8F%E7%AC%94/">随笔</a></li>
		        
					<li style="width: 33.333333333333336%"><a href="/archives/index.html">归档</a></li>
		        
				</ul>
			</nav>
		</header>				
	</div>
	<div class="mobile-mask" style="display:none" q-show="isShow"></div>
</nav>

      <div id="wrapper" class="body-wrap">
        <div class="menu-l">
          <div class="canvas-wrap">
            <canvas data-colors="#eaeaea" data-sectionHeight="100" data-contentId="js-content" id="myCanvas1" class="anm-canvas"></canvas>
          </div>
          <div id="js-content" class="content-ll">
            
    <i class="fa fa-thumb-tack"></i>
    <!-- <font color=7D26CD>置顶</font> -->
    <span class="post-meta-divider"></span>
  
<article id="post-Mysql数据库" class="article article-type-post " itemscope itemprop="blogPost">
  <div class="article-inner">
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      Mysql数据库
    </h1>
  

        
        <a href="/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/" class="archive-article-date">
  	<time datetime="2021-11-08T09:27:00.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2021-11-08</time>
</a>
        
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id><a href="#" class="headerlink" title></a></h1><p>摘要：本篇blog讲解Mysql数据库</p>
<span id="more"></span>

<h3 id="关系型数据库——MySql"><a href="#关系型数据库——MySql" class="headerlink" title="关系型数据库——MySql"></a>关系型数据库——MySql</h3><h3 id="零-1、数据库基础知识"><a href="#零-1、数据库基础知识" class="headerlink" title="零-1、数据库基础知识"></a>零-1、数据库基础知识</h3><h4 id="0-1-数据库"><a href="#0-1-数据库" class="headerlink" title="0.1 数据库"></a>0.1 数据库</h4><p>数据库：数据的集合（DB）</p>
<p>数据库管理系统（DBMS）：管理数据库的软件，通常用于建立、使用和维护数据库</p>
<p>数据库系统（DBS）：DB+DBMS+DBA</p>
<p>数据库管理员（DBA）：管理人员</p>
<h4 id="0-2-基本概念"><a href="#0-2-基本概念" class="headerlink" title="0.2 基本概念"></a>0.2 基本概念</h4><p>1、元组：数据库中的一条记录就是一个元组——表中的行</p>
<p>2、码：表中的列</p>
<p>3、候选码：某列或者列的组合能够确定唯一的元组，该列或列组合就是候选码</p>
<p>4、主码（键）：从候选码选出来的，一个实体集只能有一个主键</p>
<p>5、外码（键）：某列是另一张表中的主码，则该列为外码</p>
<p>6、主属性：候选码中出现过的列</p>
<p>7、非主属性：不在任一个候选码中的列</p>
<h4 id="0-3-外键与级联"><a href="#0-3-外键与级联" class="headerlink" title="0.3 外键与级联"></a>0.3 外键与级联</h4><p>外键：A表的列m是B表的主键，则m是外键</p>
<p>级联：A表的列m更新了，B表的主键也要更新</p>
<p>禁止外键与级联的原因</p>
<ul>
<li>外键影响数据库的插入速度，因为每次插入前【？】</li>
<li>外键需要请求对其他表内部加锁，可能导致死锁【？】</li>
<li>外键对分库分表不友好，分库分表时外键是无法生效的</li>
</ul>
<h4 id="0-4-ER图"><a href="#0-4-ER图" class="headerlink" title="0.4 ER图"></a>0.4 ER图</h4><p>Entity Relationship Diagram【实体-联系图】，提供了表示实体类型、属性和联系的方法</p>
<p>两张表之间的关系有：</p>
<p>多对多（m：n）、1对多、多对1</p>
<img src="/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/4717673e36966e0e4b33fccfd753f6ea.png" alt="ER图示例" style="zoom:67%;">

<img src="/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/5897753dfb301dfa3a814ab06e718a5e.png" alt="关系模型" style="zoom:67%;">





<p><strong>补充：drop、delete等</strong></p>
<h3 id="零-2、字符集"><a href="#零-2、字符集" class="headerlink" title="零-2、字符集"></a>零-2、字符集</h3><h4 id="0-1-字符集"><a href="#0-1-字符集" class="headerlink" title="0.1 字符集"></a>0.1 字符集</h4><p><strong>字符</strong> 是各种文字和符号的统称，包括各个国家文字、标点符号、表情、数字等等。 </p>
<p><strong>字符集</strong> 是一系列字符的集合。字符集的种类较多，每个字符集可以表示的字符范围通常不同，就比如说有些字符集是无法表示汉字的。</p>
<p><strong>计算机只能存储二进制的数据，那英文、汉字、表情等字符应该如何存储呢？</strong></p>
<p>我们要将这些字符和二级制的数据一一对应起来，比如说字符“a”对应“01100001”，反之，“01100001”对应 “a”。我们将字符对应二进制数据的过程称为”<strong>字符编码</strong>“，反之，二进制数据解析成字符的过程称为“<strong>字符解码</strong>”。</p>
<h4 id="0-2-常见的字符集"><a href="#0-2-常见的字符集" class="headerlink" title="0.2 常见的字符集"></a>0.2 常见的字符集</h4><p>常见的字符集有 ASCII、GB2312、GBK、UTF-8……。</p>
<p>不同的字符集的主要区别在于：</p>
<ul>
<li>可以表示的字符范围</li>
<li>编码方式</li>
</ul>
<p><strong>1）ASCII：主要用于英语的字符集</strong></p>
<p>一个ASCII码是8位，比如“a”对应的 ASCII 码是“01100001”。不过，最高位是 0 仅仅作为校验位，其余 7 位使用 0 和 1 进行组合，所以，ASCII 字符集可以定义 128（2^7）个字符。其中有33个控制字符，如回车</p>
<blockquote>
<p>ASCII扩展字符集</p>
<p>ASCII 扩展字符集使用 8 位（bits）表示一个字符，所以，ASCII 扩展字符集可以定义 256（2^8）个字符。</p>
</blockquote>
<p>A：65</p>
<p>a：97</p>
<p>0：48</p>
<p><strong>2）GB2312：对汉字友好字符集</strong></p>
<p>对于英语字符，GB2312 编码和 ASCII 码是相同的，1 字节编码即可。对于非英字符，需要 2 字节编码。</p>
<p>共收录 6700 多个汉字，范围较小</p>
<p><strong>3）GBK：对2312的扩展</strong></p>
<p>收录20000+汉字</p>
<p><strong>4）GB18030：最全面汉字字符</strong></p>
<p>汉字70000+</p>
<p><strong>5）BIG5：主要针对的是繁体中文</strong></p>
<p>收录汉字13000多</p>
<p><strong>6）Unicode</strong></p>
<blockquote>
<p><strong>乱码问题</strong></p>
<p>由于每个文件很可能采用不同的字符集。而我们刚讲了不同的字符集通常意味着不同的编码方式。那么使用错误的解码查看一个文件就会产生乱码</p>
<p>一句话：编码和解码采用了不同or不兼容的数据集</p>
</blockquote>
<p>”如果我们能够有一种字符集将世界上所有的字符都纳入其中就好了！“</p>
<p>Unicode 字符集中包含了世界上几乎所有已知的字符。不过，Unicode 字符集并没有规定如何存储这些字符（也就是如何使用二进制数据表示这些字符）。</p>
<p>然后，就有了 <strong>UTF-8</strong>（<strong>8</strong>-bit <strong>U</strong>nicode <strong>T</strong>ransformation <strong>F</strong>ormat）。类似的还有 UTF-16、 UTF-32。</p>
<p>UTF-8 使用 1 到 4 个字节为每个字符编码， UTF-16 使用 2 或 4 个字节为每个字符编码，UTF-32 固定位 4 个字节为每个字符编码。</p>
<p>UTF-8 可以根据不同的符号自动选择编码的长短，像英文字符只需要 1 个字节就够了，这一点 ASCII 字符集一样 。因此，对于英语字符，UTF-8 编码和 ASCII 码是相同的。</p>
<p>UTF-32 的规则最简单，不过缺陷也比较明显，对于英文字母这类字符消耗的空间是 UTF-8 的 4 倍之多。</p>
<h4 id="0-3-MySql字符集"><a href="#0-3-MySql字符集" class="headerlink" title="0.3 MySql字符集"></a>0.3 MySql字符集</h4><p>我们通常都使用UTF-8，但是MySql有两套utf8实现</p>
<p><strong><code>utf8mb3</code></strong> ： <code>utf8</code>编码只支持<code>1-3</code>个字节 。 在 <code>utf8</code> 编码中，中文是占 3 个字节，其他数字、英文、符号占一个字节。但 emoji 符号占 4 个字节，一些较复杂的文字、繁体字也是 4 个字节。</p>
<p><strong><code>utf8mb4</code></strong> ： UTF-8 的完整实现，正版！最多支持使用 4 个字节表示字符，因此，可以用来存储 emoji 符号。</p>
<p><strong>utf8默认是utf8mb3</strong></p>
<p>产生原因主要是历史原因，所以最好用utf8mb4，避免报错</p>
<h3 id="一、Intro"><a href="#一、Intro" class="headerlink" title="一、Intro"></a>一、Intro</h3><blockquote>
<p>一些易错点放在前面：</p>
<p>1、SQLyog在执行单条语句时，除非你把这条语句选中，否则请确保你上一条语句正确结尾了</p>
<p>2、查询时，通常带上distinct是件好事，如果题目明确要求考虑重复另说</p>
</blockquote>
<blockquote>
<p>javaEE阶段——企业级开发</p>
<p>前端：页面展示</p>
<p>后端：连接数据库JDBC，连接前端（控制、控制视图跳转、给前端传递数据）</p>
<p>数据库：存数据</p>
</blockquote>
<h4 id="1-1-为什么学习数据库"><a href="#1-1-为什么学习数据库" class="headerlink" title="1.1 为什么学习数据库"></a>1.1 为什么学习数据库</h4><ol>
<li>岗位需求</li>
<li>现在的世界：是大数据时代——得数据者得天下</li>
<li>被迫需求：存数据</li>
<li>是所有软件体系中最核心的存在</li>
</ol>
<h4 id="1-2-什么是数据库"><a href="#1-2-什么是数据库" class="headerlink" title="1.2 什么是数据库"></a>1.2 什么是数据库</h4><p>数据库：DB，DataBase</p>
<p>概念：数据仓库，存储数据，软件，安装在操作系统上。可以存储大量数据</p>
<p>作用：存数据、管理数据</p>
<h4 id="1-3-数据库分类"><a href="#1-3-数据库分类" class="headerlink" title="1.3 数据库分类"></a>1.3 数据库分类</h4><p>关系型数据库    {行：列}：Mysql、SQL Server、Oracle等</p>
<p>关系型数据库意思就是存储的是数据之间的关系。</p>
<blockquote>
<p>关系可以理解为多个值本来各不相关，但是放在同一行里，就对应起来了，这就是关系</p>
</blockquote>
<p>非关系型数据库    {key:value}：Json、Redis、MongDB：以对象存储，通过对象的自身属性来决定 （NoSQL =  Not only SQL）</p>
<h4 id="1-4-MySQL"><a href="#1-4-MySQL" class="headerlink" title="1.4 MySQL"></a>1.4 MySQL</h4><p>开源，成熟，可定制，默认端口号是3306</p>
<p>数据库集群：多个数据库集成使用</p>
<h4 id="1-5-安装"><a href="#1-5-安装" class="headerlink" title="1.5 安装"></a>1.5 安装</h4><p>注意启动端口为mysql80</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">net start mysql80</span><br><span class="line">net stop mysql80</span><br></pre></td></tr></table></figure>

<h4 id="1-6-管理软件：SQLyog"><a href="#1-6-管理软件：SQLyog" class="headerlink" title="1.6 管理软件：SQLyog"></a>1.6 管理软件：SQLyog</h4><ul>
<li>连接：<strong>localhost=127.0.0.1</strong></li>
</ul>
<p>操作：</p>
<blockquote>
<p>新建一个数据库</p>
<p>新建一张表</p>
</blockquote>
<p>每一个sqlyog的执行操作，本质就是对应了一条sql语句，可以在历史记录中查看</p>
<h4 id="1-7-连接数据库"><a href="#1-7-连接数据库" class="headerlink" title="1.7 连接数据库"></a>1.7 连接数据库</h4><p>命令行连接数据库：</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mysql <span class="operator">-</span>uroot <span class="operator">-</span>p <span class="comment">--连接数据库</span></span><br></pre></td></tr></table></figure>

<p>操作数据库</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">update mysql .<span class="keyword">user</span> <span class="keyword">set</span> authentication_string<span class="operator">=</span>password(<span class="string">&#x27;&#x27;</span>) <span class="keyword">where</span> <span class="keyword">user</span><span class="operator">=</span><span class="string">&#x27;root&#x27;</span> <span class="keyword">and</span> Host <span class="operator">=</span> <span class="string">&#x27;localhost&#x27;</span>; <span class="comment">--修改密码</span></span><br><span class="line">flush privilege; <span class="comment">--刷新权限</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- sql语句都使用分号结尾</span></span><br><span class="line"><span class="keyword">show</span> databases; <span class="comment">--查看所有的数据库</span></span><br><span class="line"></span><br><span class="line">use school; <span class="comment">--切换数据库：使用use命令</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">show</span> tables; <span class="comment">--查看所有的表</span></span><br><span class="line"><span class="keyword">describe</span> student; <span class="comment">--显示数据库中所有表的信息</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">create</span> database westos; <span class="comment">--创建一个数据库</span></span><br><span class="line"></span><br><span class="line">exit; <span class="comment">--退出连接</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- 单行注释</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">我是多行注释</span></span><br><span class="line"><span class="comment">*/</span></span><br></pre></td></tr></table></figure>

<h3 id="二、MySQL表管理"><a href="#二、MySQL表管理" class="headerlink" title="二、MySQL表管理"></a>二、MySQL表管理</h3><p><strong>操作数据库→操作数据库中的表→操作数据库中表的数据</strong></p>
<p><strong>mysql关键字不区分大小写！</strong></p>
<h4 id="2-0-数据库五大语言："><a href="#2-0-数据库五大语言：" class="headerlink" title="2.0 数据库五大语言："></a>2.0 数据库五大语言：</h4><p>DDL：定义【data definition language】<code>create</code>、<code>alter</code>、<code>drop</code></p>
<p>DML：操作【data manipulation language】<code>update</code>、<code>insert</code>、<code>delete</code></p>
<p>DQL：查询【data query language】<code>select</code></p>
<p>DCL： 数据库控制【Data Control Language】<code>grant</code>、<code>revoke</code></p>
<p>TCL：事务控制【Transaction Control Language】<code>commit</code>、<code>rollback</code></p>
<blockquote>
<p>delete是DML语言，支持事务回滚。而truncate是DDL语言，不支持回滚</p>
<p>delete删数据，truncate删表</p>
</blockquote>
<h4 id="2-1-DDL语言操作数据库"><a href="#2-1-DDL语言操作数据库" class="headerlink" title="2.1 DDL语言操作数据库"></a>2.1 DDL语言操作数据库</h4><p>1、创建数据库</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">CREATE</span> DATABASE [IF <span class="keyword">NOT</span> <span class="keyword">EXISTS</span>] westos;</span><br><span class="line"><span class="comment">-- 括号里可以不写</span></span><br></pre></td></tr></table></figure>

<p>2、删除数据库 </p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">DROP</span> DATABASE [IF <span class="keyword">EXISTS</span>] westos;</span><br></pre></td></tr></table></figure>

<p>3、使用数据库</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">USE school;</span><br><span class="line"><span class="comment">--如果表面或者字段名是一种特殊字符，就需要带``</span></span><br></pre></td></tr></table></figure>

<p>4、查看数据库</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SHOW</span> DATABASES;<span class="comment">--查看所有的数据库</span></span><br></pre></td></tr></table></figure>

<h4 id="2-2-数据库的列类型"><a href="#2-2-数据库的列类型" class="headerlink" title="2.2 数据库的列类型"></a>2.2 数据库的列类型</h4><p>==无论你int后面写多少，int能存储的范围是不会变的，这个东西影响的是显示宽度==</p>
<p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/chenmingjun/p/10556206.html">【MySQL】MySQL 中的 int(11) 到底代表什么意思？ - 黑泽君 - 博客园 (cnblogs.com)</a></p>
<h4 id="数值"><a href="#数值" class="headerlink" title="数值"></a>数值</h4><p>整数</p>
<ul>
<li>tinyint    十分小的数据（一个字节）</li>
<li>smallint    较小的数据 （2个字节）</li>
<li>midiumint    中等大小的数据（3个字节）</li>
<li><strong>int</strong>    标准整数（4个字节）</li>
<li>bigint    较大的数据（8个字节）</li>
</ul>
<p>小数</p>
<ul>
<li>float    浮点数（4个字节）</li>
<li>double    浮点数    （8个字节）</li>
<li>decimal    字符串形式的浮点数（金融计算的时候，一般用）</li>
</ul>
<p>字符串</p>
<ul>
<li>char    字符串固定大小 0~255个字符</li>
<li><strong>varchar</strong>    可变字符串0~65535    常用    对应java String</li>
<li>tinytext    微型文本 2^8-1</li>
<li><strong>text</strong>    文本串 2^16-1    保存大文本</li>
</ul>
<p>时间</p>
<ul>
<li>date    yyyyMMDD</li>
<li>time    hhMMss</li>
<li><strong>datetime    年月日时分秒</strong></li>
<li><strong>timestamp    时间戳 1970.1.1到现在</strong></li>
<li>year    年份表示</li>
</ul>
<p>null</p>
<ul>
<li>没有值</li>
<li>==注意，不要使用null进行运算，结果为null==</li>
</ul>
<h4 id="2-3-数据库的字段属性"><a href="#2-3-数据库的字段属性" class="headerlink" title="2.3 数据库的字段属性"></a>2.3 数据库的字段属性</h4><p>Unsigned</p>
<ul>
<li>无符号的整数</li>
<li>该列不能为负数</li>
</ul>
<p>zerofill</p>
<ul>
<li>0填充：不足的位数使用0来填充</li>
<li>int（3） 5→005</li>
</ul>
<p>自增</p>
<ul>
<li>自动在上一条记录的基础上+1（默认）</li>
<li>通常用来设计唯一的主键~ index，必须是整数类型</li>
<li>可以自定义设计主键自增的起始值和步长</li>
</ul>
<p>非空</p>
<ul>
<li>在设置为not null的情况下，如果不赋值，就会报错</li>
<li>设置为可null的情况下：如果不填写值，默认就是null</li>
</ul>
<p>默认</p>
<ul>
<li>设置默认值</li>
<li>例：sex，默认值为男</li>
</ul>
<blockquote>
<p>规范：每一个表都必须存在以下五个字段，未来做项目用的</p>
<p><code>id</code>主键</p>
<p><code>version</code>乐观锁</p>
<p><code>is_delete</code>伪删除</p>
<p><code>gmt_create</code>创建时间</p>
<p><code>gmt_update</code>修改时间</p>
</blockquote>
<p>注意：</p>
<p>int(10)：表示显示10位，即还是能存16位的数，但是只显示10位，和0填充有关</p>
<p>varchar(10)：表示确实只能存10位</p>
<h4 id="2-4-创建数据库表（sql）"><a href="#2-4-创建数据库表（sql）" class="headerlink" title="2.4 创建数据库表（sql）"></a>2.4 创建数据库表（sql）</h4><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="comment">-- 注意：</span></span><br><span class="line"><span class="comment">-- 括号代表位数</span></span><br><span class="line"><span class="comment">-- NOT NULL 非空</span></span><br><span class="line"><span class="comment">-- AUTO_INCREMENT 自增</span></span><br><span class="line"><span class="comment">-- comment 注释</span></span><br><span class="line"><span class="comment">-- DEFAULT 默认值</span></span><br><span class="line"><span class="comment">-- PRIMARY_KEY 主键:一般一个表只有一个主键</span></span><br><span class="line"><span class="comment">--</span></span><br><span class="line"><span class="comment">-- 注意:</span></span><br><span class="line"><span class="comment">-- 使用英文括号，表的名称和字段使用``括起来</span></span><br><span class="line"><span class="comment">-- 每一条语句后面加逗号(最后一条语句可以不加)</span></span><br><span class="line"><span class="comment">-- 字符串用单引号括起来</span></span><br><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> IF <span class="keyword">NOT</span> <span class="keyword">EXISTS</span> `student` (</span><br><span class="line">    `id` <span class="type">INT</span>(<span class="number">4</span>) <span class="keyword">NOT</span> <span class="keyword">NULL</span> AUTO_INCREMENT COMMENT <span class="string">&#x27;学号&#x27;</span>,</span><br><span class="line">    `name` <span class="type">VARCHAR</span>(<span class="number">30</span>) <span class="keyword">NOT</span> <span class="keyword">NULL</span> <span class="keyword">DEFAULT</span> <span class="string">&#x27;匿名&#x27;</span> COMMENT <span class="string">&#x27;姓名&#x27;</span>,</span><br><span class="line">    `pwd` <span class="type">VARCHAR</span>(<span class="number">20</span>) <span class="keyword">NOT</span> <span class="keyword">NULL</span> <span class="keyword">DEFAULT</span> <span class="string">&#x27;123456&#x27;</span> COMMENT <span class="string">&#x27;密码&#x27;</span>,</span><br><span class="line">    `sex` <span class="type">VARCHAR</span>(<span class="number">2</span>) <span class="keyword">NOT</span> <span class="keyword">NULL</span> <span class="keyword">DEFAULT</span> <span class="string">&#x27;女&#x27;</span> COMMENT <span class="string">&#x27;性别&#x27;</span>,</span><br><span class="line">    `birthday` DATETIME <span class="keyword">DEFAULT</span> <span class="keyword">NULL</span> COMMENT <span class="string">&#x27;出生日期&#x27;</span>,</span><br><span class="line">    `address` <span class="type">VARCHAR</span>(<span class="number">100</span>) <span class="keyword">DEFAULT</span> <span class="keyword">NULL</span> COMMENT <span class="string">&#x27;家庭住址&#x27;</span>,</span><br><span class="line">    `email` <span class="type">VARCHAR</span>(<span class="number">30</span>) <span class="keyword">DEFAULT</span> <span class="keyword">NULL</span> COMMENT <span class="string">&#x27;邮箱&#x27;</span>,</span><br><span class="line">    <span class="keyword">PRIMARY</span> KEY(`id`)</span><br><span class="line">)ENGINE<span class="operator">=</span>INNODB <span class="keyword">DEFAULT</span> CHARSET<span class="operator">=</span>utf8</span><br></pre></td></tr></table></figure>

<h5 id="格式"><a href="#格式" class="headerlink" title="格式"></a>格式</h5><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> [IF <span class="keyword">NOT</span> <span class="keyword">EXISTS</span>] `表名`(</span><br><span class="line">    `字段名` 列类型 [属性][索引][注释],</span><br><span class="line">    `字段名` 列类型 [属性][索引][注释],</span><br><span class="line">    ......</span><br><span class="line">    `字段名` 列类型 [属性][索引][注释]</span><br><span class="line">)[表类型][字符集设置][注释]</span><br></pre></td></tr></table></figure>

<p>逆向查看</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SHOW</span> <span class="keyword">CREATE</span> DATABASE school; <span class="comment">-- 查看创建数据库的语句</span></span><br><span class="line"><span class="keyword">SHOW</span> <span class="keyword">CREATE</span> <span class="keyword">TABLE</span> student;</span><br><span class="line"><span class="keyword">DESC</span> student;</span><br></pre></td></tr></table></figure>



<p><strong>设置数据库表的字符集编码</strong></p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">CHARSET<span class="operator">=</span>utf8mb4</span><br></pre></td></tr></table></figure>

<p>不设置的话，会是mysql默认的字符集编码（不支持中文）</p>
<h4 id="2-5-查看数据库引擎"><a href="#2-5-查看数据库引擎" class="headerlink" title="2.5 查看数据库引擎"></a>2.5 查看数据库引擎</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mysql&gt; show engines;//先连接数据库才可</span><br></pre></td></tr></table></figure>

<p>默认InnoDB、老版本是MyISAM</p>
<table>
<thead>
<tr>
<th></th>
<th>MyISAM</th>
<th>INNODB</th>
</tr>
</thead>
<tbody><tr>
<td>事务支持</td>
<td>不支持</td>
<td>支持</td>
</tr>
<tr>
<td>数据行锁定【行级锁】</td>
<td>不支持（表锁）</td>
<td>支持</td>
</tr>
<tr>
<td>外键约束</td>
<td>不支持</td>
<td>支持</td>
</tr>
<tr>
<td>全文索引</td>
<td>支持</td>
<td>不支持</td>
</tr>
<tr>
<td>表空间的大小</td>
<td>较小</td>
<td>较大，约为两倍</td>
</tr>
<tr>
<td>安全性</td>
<td>崩溃后无法安全恢复</td>
<td>更安全</td>
</tr>
</tbody></table>
<p>详解：</p>
<p>1）行级锁：</p>
<p>MyISAM锁的是整张表←→InnoDB锁的是某条记录，InnoDB在并发的时候效率高</p>
<p>2）事务：</p>
<p>InnoDB支持事务，从而可以提交（commit）和回滚（rollback）</p>
<p>3）外键：</p>
<p>InnoDB支持，MyISAM不支持</p>
<p>4）安全性：</p>
<p>InnoDB在数据库异常崩溃后，重新启动时会恢复到崩溃前的状态，恢复过程依赖于<code>redo log</code></p>
<p>5）MVCC：</p>
<p>InnoDB支持【？】</p>
<p><strong>在物理空间存在的位置</strong></p>
<p>所有的数据库文件都存在在data目录下，一个文件夹就是一个数据库</p>
<p>本质还是文件的存储</p>
<p>MySQL引擎在物理文件上的区别</p>
<ul>
<li>InnoDB在数据库表中只有一个*.frm文件，以及上级目录下的ibdata文件</li>
<li>MYISAM<ul>
<li>*.frm    表结构的定义文件</li>
<li>*.MYD    数据文件</li>
<li>*,MYI    索引文件（Index）</li>
</ul>
</li>
</ul>
<h4 id="2-6-修改和删除表"><a href="#2-6-修改和删除表" class="headerlink" title="2.6 修改和删除表"></a>2.6 修改和删除表</h4><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- 修改表  ALTER TABLE 旧表名 RENAME AS 新表名</span></span><br><span class="line"><span class="keyword">ALTER</span> <span class="keyword">TABLE</span> student RENAME <span class="keyword">AS</span> teacher;</span><br><span class="line"><span class="comment">-- 增加表的字段 ALTER TABLE 表名 ADD 字段名 列属性</span></span><br><span class="line"><span class="keyword">ALTER</span> <span class="keyword">TABLE</span> teacher <span class="keyword">ADD</span> age <span class="type">INT</span>(<span class="number">11</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 修改约束 ALTER TABLE 表名 MODIFY 字段名 列属性[]</span></span><br><span class="line"><span class="keyword">ALTER</span> <span class="keyword">TABLE</span> teacher MODIFY age <span class="type">VARCHAR</span>(<span class="number">11</span>);</span><br><span class="line"><span class="comment">-- 重命名 ALTER TABLE 表名 CHANGE 字段旧名 字段新名 列属性[];</span></span><br><span class="line"><span class="keyword">ALTER</span> <span class="keyword">TABLE</span> teacher CHANGE age age1 <span class="type">INT</span>(<span class="number">1</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 删除表的字段</span></span><br><span class="line"><span class="keyword">ALTER</span> <span class="keyword">TABLE</span> teacher <span class="keyword">DROP</span> age1 </span><br></pre></td></tr></table></figure>

<h4 id="2-7-删除表"><a href="#2-7-删除表" class="headerlink" title="2.7 删除表"></a>2.7 删除表</h4><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">DROP</span> <span class="keyword">TABLE</span> IF <span class="keyword">EXISTS</span> teacher;</span><br></pre></td></tr></table></figure>

<p>==所有的创建和删除操作尽量加上判断，以免报错== </p>
<p>注意点：</p>
<ul>
<li>字段名：尽量用``包裹</li>
<li>sql关键字大小写不敏感，建议写小写</li>
<li>符号用英文</li>
</ul>
<h3 id="三、Mysql数据管理"><a href="#三、Mysql数据管理" class="headerlink" title="三、Mysql数据管理"></a>三、Mysql数据管理</h3><h4 id="3-1-外键"><a href="#3-1-外键" class="headerlink" title="3.1 外键"></a>3.1 外键</h4><p>搞清几个关系：</p>
<p>A的x字段和B的x字段对应，且x在B中作为主键存在，那么：</p>
<p>A表是外键：    </p>
<p>​    &lt;==&gt;A引用到B表的x字段（A表是引用表，B表是被引用表，即从A的x字段可以在B中找到一条完整的记录，从这个角度看，A引出了B）</p>
<p>​    &lt;==&gt;A表是从表，B表是主表</p>
<p>外键的定义：</p>
<p><strong>学生表(学号，姓名，性别，班级)</strong>  其中每个学生的学号是唯一的，学号就是一个主键 </p>
<p><strong>课程表(课程编号,课程名,学分)</strong>  其中课程编号是唯一的,课程编号就是一个主键 </p>
<p><strong>成绩表(学号,课程号,成绩)</strong> </p>
<p>成绩表中的学号不是成绩表的主键，但它和学生表中的学号相对应，并且学生表中的学号是学生表的主键，<strong>则称成绩表中的学号是学生表的外键</strong>，同理<strong>成绩表中的课程号是课程表的外键</strong> </p>
<p><strong>方式一：在创建表的时候创建外键</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">-- 以下这两句的作用是创建一个由student表指向grade表的外键</span><br><span class="line">KEY `FK_gradeid` (`gradeid`),-- student表的gradeid属性作为外键，这个外键起名为FK_gradeid</span><br><span class="line">CONSTRAINT `FK_gradeid` FOREIGN KEY (`gradeid`) REFERENCES `grade` (`gradeid`)-- 这个来自student——gradeid的名为FK_gradeid的键作为了grade表的外键，其对应的是gradeid</span><br></pre></td></tr></table></figure>
<p>注：</p>
<p>如果A（从表）表中的某条属性作为了B表（主表）的外键，那么在A表删除之前，B表不能被删除（如果B表被删除，A表的完整性将被破坏：按照A表的外键来找对应的值，却找不到）</p>
<p><strong>方式二：创建完表之后自己添加外键</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">-- 创建表</span><br><span class="line">ALTER TABLE `student` ADD CONSTRAINT `FK_gradeid` FOREIGN KEY(`gradeid`) REFERENCES `grade` (`gradeid`);</span><br><span class="line"></span><br><span class="line">-- 总结</span><br><span class="line">-- alter：改变表——添加约束——</span><br><span class="line">ALTER TABLE `引用的主体` ADD CONSTRAINT `外键名` FOREIGN KEY(`x字段`) REFERENCES `引用的客体` (`x字段`);</span><br></pre></td></tr></table></figure>

<p>以上都是物理外键：数据库级别的外键，我们不建议使用！（避免数据库过多，造成困扰：举个最简单的例子，如果不把从表给删干净，主表都没法删，在数据库很多的情况下，关系混乱）</p>
<p>更好的方法：</p>
<ul>
<li>数据库就是单纯的表，只用来存数据，只有行和列（行代表记录，列代表字段）</li>
<li><strong>想使用外键，将来用程序去实现</strong></li>
</ul>
<h4 id="3-2-DML语言（增删改）"><a href="#3-2-DML语言（增删改）" class="headerlink" title="3.2 DML语言（增删改）"></a>3.2 DML语言（增删改）</h4><blockquote>
<p>反引号是用来标注列名的，字符串要用单引号</p>
</blockquote>
<p><em>DML</em>一般指数据操纵语言。 <strong>数据操纵语言</strong>（Data Manipulation Language, <em>DML</em>）是用于数据库操作</p>
<p>DML：</p>
<ul>
<li>insert</li>
<li>update（修改&amp;更新）</li>
<li>delete</li>
</ul>
<h5 id="3-2-1-添加"><a href="#3-2-1-添加" class="headerlink" title="3.2.1 添加"></a>3.2.1 添加</h5><p><strong>INSERT</strong></p>
<p>语法：</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> 表名(字段<span class="number">1</span>,字段<span class="number">2</span>,字段<span class="number">3</span>) <span class="keyword">VALUES</span> (值<span class="number">1</span>,值<span class="number">2</span>,值<span class="number">3</span>),(值<span class="number">1</span>,值<span class="number">2</span>,值<span class="number">3</span>)</span><br><span class="line"><span class="comment">-- 值的每个括号代表一条记录</span></span><br><span class="line"><span class="comment">-- 值如果是数就不用引号，如果是字符串要引号&#x27;&#x27;</span></span><br></pre></td></tr></table></figure>

<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> student (`name`,`pwd`,`sex`) <span class="keyword">VALUES</span> (<span class="string">&#x27;张三&#x27;</span>,<span class="string">&#x27;aaaaaa&#x27;</span>,<span class="string">&#x27;男&#x27;</span>),(<span class="string">&#x27;李四&#x27;</span>,<span class="string">&#x27;bbbbbbb&#x27;</span>,<span class="string">&#x27;女&#x27;</span>);</span><br><span class="line"><span class="comment">-- 如果要插入多个值，请用逗号隔开</span></span><br><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> `student` <span class="keyword">VALUES</span> (<span class="number">6</span>,<span class="string">&#x27;王五&#x27;</span>,<span class="string">&#x27;abccba&#x27;</span>,<span class="string">&#x27;中&#x27;</span>,<span class="string">&#x27;2000-1-1&#x27;</span>,<span class="string">&#x27;xian&#x27;</span>,<span class="string">&#x27;88888888@qq.com&#x27;</span>);</span><br><span class="line"><span class="comment">-- 如果省略字段名，后面请一一匹配</span></span><br><span class="line"><span class="comment">-- 日期按照字符串写</span></span><br></pre></td></tr></table></figure>

<p>注意事项：</p>
<ol>
<li><p>字段和字段之间使用英文逗号隔开</p>
</li>
<li><p>字段可以省略，但是后面的值要一一对应，不能少</p>
</li>
<li><p>可以同时插入多条数据，VALUES后面的值，使用逗号隔开：一个括号就代表一条数据</p>
</li>
<li><p>表名和字段名最好加上``，防止和关键字冲突，如name字段和name关键字冲突，加上反引号可以解决</p>
</li>
</ol>
<h5 id="3-2-2-修改"><a href="#3-2-2-修改" class="headerlink" title="3.2.2 修改"></a>3.2.2 修改</h5><p>条件——运算符</p>
<p>放在where关键字后面</p>
<table>
<thead>
<tr>
<th>操作符</th>
<th>含义</th>
<th>范围</th>
<th>结果</th>
</tr>
</thead>
<tbody><tr>
<td>=</td>
<td>等于</td>
<td>5=6</td>
<td>false</td>
</tr>
<tr>
<td>&lt;&gt;或!=</td>
<td>不等于</td>
<td>5&lt;&gt;6</td>
<td>true</td>
</tr>
<tr>
<td>&gt;</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>&lt;</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>&lt;=</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>&gt;=</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>BETWEEN…AND…</td>
<td>在某个范围内</td>
<td>[2,5]</td>
<td></td>
</tr>
<tr>
<td>AND</td>
<td>且</td>
<td>5&gt;1 AND 1&gt;2</td>
<td>false</td>
</tr>
<tr>
<td>OR</td>
<td>或</td>
<td>5&gt;1 OR 1&gt;2</td>
<td></td>
</tr>
</tbody></table>
<p>语法：</p>
<blockquote>
<p>UPDATE 表名 SET 字段 = 值[, 字段=值, 字段=值] where [条件]</p>
</blockquote>
<p>注意：</p>
<ul>
<li>条件如果不指定会修改全部记录</li>
<li>value也可以变量（通常用于日期）</li>
</ul>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">UPDATE `student` <span class="keyword">SET</span> `name`<span class="operator">=</span><span class="string">&#x27;mars&#x27;</span> <span class="keyword">WHERE</span> id <span class="operator">=</span> <span class="number">1</span>;</span><br><span class="line"><span class="comment">-- 不指定条件将会修改全部数据</span></span><br><span class="line">UPDATE `student` <span class="keyword">SET</span> `name`<span class="operator">=</span><span class="string">&#x27;sram&#x27;</span>; </span><br><span class="line"><span class="comment">-- 修改多个属性，逗号隔开</span></span><br><span class="line">UPDATE `student` <span class="keyword">SET</span> `name`<span class="operator">=</span><span class="string">&#x27;kuangshen&#x27;</span>,`email`<span class="operator">=</span><span class="string">&#x27;123456465@qq.com&#x27;</span> <span class="keyword">WHERE</span> id <span class="operator">=</span> <span class="number">1</span>;</span><br><span class="line"><span class="comment">-- 多个判断条件</span></span><br><span class="line">UPDATE `student` <span class="keyword">SET</span> `name`<span class="operator">=</span><span class="string">&#x27;marss&#x27;</span> <span class="keyword">WHERE</span> `name`<span class="operator">=</span><span class="string">&#x27;sram&#x27;</span> <span class="keyword">AND</span> sex<span class="operator">=</span><span class="string">&#x27;男&#x27;</span>;</span><br><span class="line">UPDATE `student` <span class="keyword">SET</span> `name`<span class="operator">=</span><span class="string">&#x27;msdfsarss&#x27;</span> <span class="keyword">WHERE</span> `id` <span class="keyword">BETWEEN</span> <span class="number">2</span> <span class="keyword">AND</span> <span class="number">5</span> <span class="keyword">AND</span> sex<span class="operator">=</span><span class="string">&#x27;男&#x27;</span>;</span><br><span class="line"><span class="comment">-- value是变量的情况</span></span><br><span class="line">UPDATE `student` <span class="keyword">SET</span> `birthday`<span class="operator">=</span> <span class="built_in">CURRENT_TIME</span> <span class="keyword">WHERE</span> id <span class="operator">=</span> <span class="number">1</span>;</span><br></pre></td></tr></table></figure>



<h5 id="3-2-3-删除"><a href="#3-2-3-删除" class="headerlink" title="3.2.3 删除"></a>3.2.3 删除</h5><p><strong>DELETE命令</strong></p>
<p>==语法：delete from 表名 [where 条件]==</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">DELETE</span> <span class="keyword">FROM</span> `student` <span class="comment">--清空表：不会影响自增</span></span><br><span class="line"><span class="keyword">DELETE</span> <span class="keyword">FROM</span> `student` <span class="keyword">WHERE</span> id <span class="operator">=</span> <span class="number">1</span>;</span><br></pre></td></tr></table></figure>

<p><strong>TRUNCATE命令</strong></p>
<p>作用：完全清空一个数据库表，表的结构和索引约束不会变</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- 清空student表</span></span><br><span class="line"><span class="keyword">TRUNCATE</span> [<span class="keyword">TABLE</span>] `test` <span class="comment">--自增会归零</span></span><br></pre></td></tr></table></figure>

<p>DELETE VS TRUNCATE</p>
<ul>
<li><p>相同：都能删除数据，不会影响表的结构</p>
</li>
<li><p>不同：</p>
<ul>
<li><p>重新设置自增列，即计数器会归零</p>
<p>例如本来id自增到10了，delete之后，下次再插数据的id是11，而TRANCATE是1</p>
</li>
<li><p>TRUNCATE 不会影响事务</p>
</li>
</ul>
</li>
</ul>
<h4 id="3-3-DQL查询数据（数据库四大语言2）"><a href="#3-3-DQL查询数据（数据库四大语言2）" class="headerlink" title="3.3 DQL查询数据（数据库四大语言2）"></a>3.3 DQL查询数据（数据库四大语言2）</h4><p>就记住Select！！再复杂的查询都是关键字select</p>
<h5 id="3-3-1-DQL"><a href="#3-3-1-DQL" class="headerlink" title="3.3.1 DQL"></a>3.3.1 DQL</h5><p>Data Query Language：数据查询语语言</p>
<ul>
<li>所有的查询操作都用它 Select</li>
<li>是数据库中最核心的语言</li>
<li>使用频率最高</li>
</ul>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- 查询全部学生 select 字段 from 表</span></span><br><span class="line"><span class="keyword">SELECT</span> <span class="operator">*</span> <span class="keyword">FROM</span> student;</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 查询指定字段</span></span><br><span class="line"><span class="keyword">SELECT</span> `StudentNO`,`StudentName` <span class="keyword">FROM</span> student;</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 别名，给查到的字段起一个名字 AS 可以给字段、表起别名</span></span><br><span class="line"><span class="keyword">SELECT</span> `StudentNO` <span class="keyword">AS</span> 学号,`StudentName` <span class="keyword">AS</span> 姓名 <span class="keyword">FROM</span> student <span class="keyword">AS</span> s;</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 函数 Concat(a,b):作用是将结果拼接为指定格式</span></span><br><span class="line"><span class="keyword">SELECT</span> CONCAT(<span class="string">&#x27;姓名: &#x27;</span>, StudentName) <span class="keyword">AS</span> 新名字 <span class="keyword">FROM</span> student;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>语法：==select 字段[,字段] from 表==</p>
<ul>
<li><p>别名：</p>
<p>通常列名不是很直观，我们在查询的时候，为了让结果更直观，可以通过as的方法给字段名起一个别名，这样在显示的时候更为直观。</p>
<p>另外，表名也可以起一个别名</p>
</li>
</ul>
<h5 id="3-3-2-指定查询手段"><a href="#3-3-2-指定查询手段" class="headerlink" title="3.3.2 指定查询手段"></a>3.3.2 指定查询手段</h5><blockquote>
<p>去重：distinct</p>
</blockquote>
<p>作用：去除select</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- 查询全部考试成绩</span></span><br><span class="line"><span class="keyword">SELECT</span> <span class="operator">*</span> <span class="keyword">FROM</span> <span class="keyword">result</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 查询有哪些同学</span></span><br><span class="line"><span class="keyword">SELECT</span> `StudentNo` <span class="keyword">FROM</span> <span class="keyword">result</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 发现重复数据，去重</span></span><br><span class="line"><span class="keyword">SELECT</span> <span class="keyword">DISTINCT</span> `StudentNo` <span class="keyword">FROM</span> <span class="keyword">result</span>;</span><br></pre></td></tr></table></figure>

<blockquote>
<p>表达式</p>
</blockquote>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> VERSION(); <span class="comment">-- 查询系统版本</span></span><br><span class="line"><span class="keyword">SELECT</span> <span class="number">100</span><span class="operator">*</span><span class="number">3</span><span class="number">-1</span> <span class="keyword">AS</span> <span class="keyword">Result</span>;<span class="comment">-- 查询计算结果</span></span><br><span class="line"><span class="keyword">SELECT</span> @<span class="variable">@auto</span>_increment_increment; <span class="comment">--查询自增的步长</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> `studentno`,`studentresult` <span class="keyword">AS</span> <span class="string">&#x27;提分后&#x27;</span> <span class="keyword">FROM</span> <span class="keyword">result</span>; </span><br><span class="line"><span class="comment">-- 学员考试+1分查看</span></span><br><span class="line"><span class="keyword">SELECT</span> `studentno`,`studentresult`<span class="operator">+</span><span class="number">1</span> <span class="keyword">AS</span> <span class="string">&#x27;提分后&#x27;</span> <span class="keyword">FROM</span> <span class="keyword">result</span>;</span><br><span class="line"><span class="keyword">SELECT</span> `studentno`,`studentresult` <span class="keyword">AS</span> <span class="string">&#x27;提分后&#x27;</span> <span class="keyword">FROM</span> <span class="keyword">result</span>;</span><br><span class="line"><span class="comment">-- 注意，并不是真的把数据库里面的数据给+1分了，只是在显示的时候+1</span></span><br></pre></td></tr></table></figure>

<p>查询不只是可以查询字段，还可以查询表达式</p>
<p>数据库中的表达式包括——文本值，列，Null函数，计算表达式，系统变量</p>
<p>select 表达式 from 表</p>
<h5 id="3-3-3-where子句表达式"><a href="#3-3-3-where子句表达式" class="headerlink" title="3.3.3 where子句表达式"></a>3.3.3 where子句表达式</h5><p>作用：检索数据中符合条件的值</p>
<p> 搜索的条件由一个或者多个表达式组成，每个条件的结果都是一个<strong>布尔值</strong></p>
<blockquote>
<p>逻辑运算符</p>
</blockquote>
<table>
<thead>
<tr>
<th>运算符</th>
<th>语法</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>and &amp;&amp;</td>
<td>a and b、a &amp;&amp; b</td>
<td>逻辑与</td>
</tr>
<tr>
<td>or ||</td>
<td>a or b、a||b</td>
<td>逻辑或</td>
</tr>
<tr>
<td>Not ！</td>
<td>not a、！a</td>
<td>逻辑非</td>
</tr>
</tbody></table>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- 查询字段时是不区分大小写的</span></span><br><span class="line"><span class="keyword">SELECT</span> studentno, studentresult <span class="keyword">FROM</span> <span class="keyword">result</span>;</span><br><span class="line"><span class="comment">-- AND</span></span><br><span class="line"><span class="keyword">SELECT</span> studentno, studentresult <span class="keyword">FROM</span> <span class="keyword">result</span></span><br><span class="line"><span class="keyword">WHERE</span> studentresult<span class="operator">&gt;=</span><span class="number">95</span> <span class="keyword">AND</span> studentresult<span class="operator">&lt;=</span><span class="number">100</span>;</span><br><span class="line"><span class="comment">-- &amp;&amp;</span></span><br><span class="line"><span class="keyword">SELECT</span> studentno, studentresult <span class="keyword">FROM</span> <span class="keyword">result</span></span><br><span class="line"><span class="keyword">WHERE</span> studentresult<span class="operator">&gt;=</span><span class="number">95</span> <span class="operator">&amp;&amp;</span> studentresult<span class="operator">&lt;=</span><span class="number">100</span>;</span><br><span class="line"><span class="comment">-- 区间查询</span></span><br><span class="line"><span class="keyword">SELECT</span> studentno, studentresult <span class="keyword">FROM</span> <span class="keyword">result</span></span><br><span class="line"><span class="keyword">WHERE</span> studentresult <span class="keyword">BETWEEN</span> <span class="number">95</span> <span class="keyword">AND</span> <span class="number">100</span>;</span><br><span class="line"><span class="comment">-- 条件：student不等于1000</span></span><br><span class="line"><span class="keyword">SELECT</span> studentno, studentresult <span class="keyword">FROM</span> <span class="keyword">result</span></span><br><span class="line"><span class="keyword">WHERE</span> studentno<span class="operator">!=</span><span class="number">1000</span>;</span><br><span class="line"><span class="comment">-- 条件：不能student=100</span></span><br><span class="line"><span class="keyword">SELECT</span> studentno, studentresult <span class="keyword">FROM</span> <span class="keyword">result</span></span><br><span class="line"><span class="keyword">WHERE</span> <span class="keyword">NOT</span> studentno <span class="operator">=</span> <span class="number">100</span>;</span><br></pre></td></tr></table></figure>

<blockquote>
<p>or自带去重</p>
<p>使用union all避免去重</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> device_id, gender,age,gpa <span class="keyword">from</span> user_profile <span class="keyword">where</span> university <span class="operator">=</span> <span class="string">&#x27;山东大学&#x27;</span></span><br><span class="line"><span class="keyword">union</span> <span class="keyword">all</span> </span><br><span class="line"><span class="keyword">select</span> device_id, gender,age,gpa <span class="keyword">from</span> user_profile <span class="keyword">where</span> gender <span class="operator">=</span> <span class="string">&#x27;male&#x27;</span>;</span><br></pre></td></tr></table></figure>


</blockquote>
<h5 id="模糊查询：比较运算符"><a href="#模糊查询：比较运算符" class="headerlink" title="模糊查询：比较运算符"></a>模糊查询：比较运算符</h5><table>
<thead>
<tr>
<th>运算符</th>
<th>语法</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>IS NULL</td>
<td>a is null</td>
<td>如果操作数为null，结果为真</td>
</tr>
<tr>
<td>IS NOT NULL</td>
<td>a is not null</td>
<td>如果操作数不为null，结果为真</td>
</tr>
<tr>
<td>BETWEEN</td>
<td>a between b and c</td>
<td>若a在b和c之间，则结果为真【左右都包含】</td>
</tr>
<tr>
<td>LIKE</td>
<td>a like b</td>
<td>SQl匹配，如果a匹配b，则结果为真</td>
</tr>
<tr>
<td>IN</td>
<td>a in (a1,a2,a3..)</td>
<td>如果a在a1，a2，a3之间，则结果为真</td>
</tr>
</tbody></table>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- ===================模糊查询====================</span></span><br><span class="line"><span class="comment">-- like结合 %（代表0到任意个字符） _（一个字符）</span></span><br><span class="line"><span class="comment">-- 查询姓李的同学</span></span><br><span class="line"><span class="keyword">SELECT</span> `studentno`,`studentname` <span class="keyword">FROM</span> `student`</span><br><span class="line"><span class="keyword">WHERE</span> studentname <span class="keyword">LIKE</span> <span class="string">&#x27;李%&#x27;</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 查询姓李的同学，名字后只有一个字</span></span><br><span class="line"><span class="keyword">SELECT</span> `studentno`,`studentname` <span class="keyword">FROM</span> `student`</span><br><span class="line"><span class="keyword">WHERE</span> studentname <span class="keyword">LIKE</span> <span class="string">&#x27;李_&#x27;</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 查询姓李的同学，名字后有两个字的</span></span><br><span class="line"><span class="keyword">SELECT</span> `studentno`,`studentname` <span class="keyword">FROM</span> `student`</span><br><span class="line"><span class="keyword">WHERE</span> studentname <span class="keyword">LIKE</span> <span class="string">&#x27;李__&#x27;</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 查询名字中有李的同学，%李%</span></span><br><span class="line"><span class="keyword">SELECT</span> `studentno`,`studentname` <span class="keyword">FROM</span> `student`</span><br><span class="line"><span class="keyword">WHERE</span> studentname <span class="keyword">LIKE</span> <span class="string">&#x27;%李%&#x27;</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">-- ================== in ====================</span></span><br><span class="line"><span class="comment">-- 查询1001，1002，1003号学员信息</span></span><br><span class="line"><span class="keyword">SELECT</span> `studentno`,`studentname` <span class="keyword">FROM</span> `student`</span><br><span class="line"><span class="keyword">WHERE</span> studentno <span class="keyword">IN</span> (<span class="number">1001</span>,<span class="number">1002</span>,<span class="number">1003</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 查询在北京朝阳和广东深圳的学生</span></span><br><span class="line"><span class="keyword">SELECT</span> `studentno`,`studentname` <span class="keyword">FROM</span> `student`</span><br><span class="line"><span class="keyword">WHERE</span> `address` <span class="keyword">IN</span> (<span class="string">&#x27;北京朝阳&#x27;</span>,<span class="string">&#x27;广东深圳&#x27;</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">-- ================== not null ===============</span></span><br><span class="line"><span class="comment">-- 查询地址不空的学生</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> <span class="operator">*</span> <span class="keyword">FROM</span> student;</span><br><span class="line"><span class="comment">-- 查询密码为空的</span></span><br><span class="line"><span class="keyword">SELECT</span> `studentno` <span class="keyword">FROM</span> student <span class="keyword">WHERE</span> loginpwd <span class="keyword">IS</span> <span class="keyword">NULL</span>;</span><br><span class="line"><span class="comment">-- 查询地址为空串的——注意：空串和空可不一样！</span></span><br><span class="line"><span class="keyword">SELECT</span> `studentno`,`studentname` <span class="keyword">FROM</span> student</span><br><span class="line"><span class="keyword">WHERE</span> address <span class="operator">=</span><span class="string">&#x27;&#x27;</span>;</span><br><span class="line"><span class="comment">-- 查询密码不空的</span></span><br><span class="line"><span class="keyword">SELECT</span> `studentno` <span class="keyword">FROM</span> student <span class="keyword">WHERE</span> loginpwd <span class="keyword">IS</span> <span class="keyword">NOT</span> <span class="keyword">NULL</span>;</span><br></pre></td></tr></table></figure>

<p>注：</p>
<ol>
<li>空串不等于空</li>
<li>% _ 只能用于LIKE（模糊查询），IN是具体查询（即全字匹配）</li>
</ol>
<h4 id="3-4-连接查询"><a href="#3-4-连接查询" class="headerlink" title="3.4 连接查询"></a>3.4 连接查询</h4><h5 id="内连接与外连接"><a href="#内连接与外连接" class="headerlink" title="内连接与外连接"></a>内连接与外连接</h5><blockquote>
<p><a target="_blank" rel="noopener" href="https://www.liaoxuefeng.com/wiki/1177760294764384/1179610888796448">连接查询 - 廖雪峰</a></p>
</blockquote>
<p>场景：我们想要查询结果是student表的name、class_id、gender、score信息和班级名称的合并</p>
<p>student表：</p>
<table>
<thead>
<tr>
<th>id</th>
<th>name</th>
<th>class_id</th>
<th>gender</th>
<th>score</th>
</tr>
</thead>
<tbody><tr>
<td>1</td>
<td>小明</td>
<td>1</td>
<td>M</td>
<td>90</td>
</tr>
<tr>
<td>2</td>
<td>小红</td>
<td>2</td>
<td>F</td>
<td>89</td>
</tr>
<tr>
<td>3</td>
<td>小军</td>
<td>4</td>
<td>M</td>
<td>99</td>
</tr>
</tbody></table>
<p>class表：</p>
<table>
<thead>
<tr>
<th>id</th>
<th>name</th>
</tr>
</thead>
<tbody><tr>
<td>1</td>
<td>一班</td>
</tr>
<tr>
<td>2</td>
<td>二班</td>
</tr>
<tr>
<td>3</td>
<td>三班</td>
</tr>
</tbody></table>
<p>那么这个需求该如何实现呢</p>
<p>可以通过连接查询——以内连接为例</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> s.id, s.name, s.class_id, c.name <span class="keyword">as</span> class_name, s.score</span><br><span class="line"><span class="keyword">FROM</span> students s</span><br><span class="line"><span class="keyword">INNER</span> <span class="keyword">JOIN</span> classes c</span><br><span class="line"><span class="keyword">ON</span> s.class_id <span class="operator">=</span> c.id;</span><br></pre></td></tr></table></figure>

<p>结果：</p>
<table>
<thead>
<tr>
<th>id</th>
<th>name</th>
<th>class_id</th>
<th>class_name</th>
<th>score</th>
</tr>
</thead>
<tbody><tr>
<td>1</td>
<td>小明</td>
<td>1</td>
<td>一班</td>
<td>90</td>
</tr>
<tr>
<td>2</td>
<td>小红</td>
<td>2</td>
<td>二班</td>
<td>89</td>
</tr>
</tbody></table>
<p>分析语法格式：</p>
<blockquote>
<p>SELECT A表的字段，B表的字段（记得指明判断字段是哪个表的，通常用别名指定：a.xx，其他AB表的独占字段无所谓，可写可不写）</p>
<p>FROM A表 （别名为a）</p>
<p>INNER JOIN B表（别名为b）</p>
<p>ON A表的字段=B表的字段;</p>
</blockquote>
<p>外连接：（左外联、右外联）</p>
<p>通常把主表（即from的表）记为左表，从表记为右表</p>
<p>这种情况下：</p>
<p>外联就是把判断字段（这里为主表的class_id 或 从表的id）中，一方不存在的记录也加入查询结果中返回</p>
<blockquote>
<p>例如：</p>
<p>左外联：主表中class_id有4这个值，而从表没有，采用左外联的方式。就会把这条记录也给展示出来，同时把另一个中也应该展示的字段补充为null（另一表由于没有这个记录导致，导致返回查询结果时，只能用null补充）</p>
<table>
<thead>
<tr>
<th>id</th>
<th>name</th>
<th>class_id</th>
<th>class_name</th>
<th>score</th>
</tr>
</thead>
<tbody><tr>
<td>3</td>
<td>小军</td>
<td>4</td>
<td>null</td>
<td>99</td>
</tr>
</tbody></table>
<ul>
<li>~~~sql<br>SELECT s.id, s.name, s.class_id, c.name class_name, s.gender, s.score<br>FROM students s<br>LEFT OUTER JOIN classes c<br>ON s.class_id = c.id;<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">右外联就是把从表中有的值给展示出来（此例中从表有id=3，name=三班），结果会展示为：</span><br><span class="line"></span><br><span class="line">| id   | name | class_id | class_name | score |</span><br><span class="line">| ---- | ---- | -------- | ---------- | ----- |</span><br><span class="line">| null | null | null     | 三班       | null  |</span><br><span class="line"></span><br><span class="line">- 注意：这里class_id（判断字段）也是null，原因是显示的是主表的class_id，**这也就解释了为何有主从表之分，如果不指明且判断字段在两张表中名字相同的话，默认主表（from的表）**</span><br><span class="line"></span><br><span class="line">- ~~~sql</span><br><span class="line">  SELECT s.id, s.name, s.class_id, c.name class_name, s.gender, s.score</span><br><span class="line">  FROM students s</span><br><span class="line">  RIGHT OUTER JOIN classes c</span><br><span class="line">  ON s.class_id = c.id;</span><br><span class="line">                              </span><br></pre></td></tr></table></figure></li>
</ul>
<p>全外联：就是都把各自有的而对方没有的都显示出来，自动补充（mysql没有）</p>
<ul>
<li>~~~sql<br>SELECT s.id, s.name, s.class_id, c.name class_name, s.gender, s.score<br>FROM students s<br>FULL OUTER JOIN classes c<br>ON s.class_id = c.id;<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">**语法对比**</span><br><span class="line"></span><br><span class="line">对比四种语法，可以发现，只有JOIN前面的限定词不同，即只需要注意限定词即可</span><br><span class="line"></span><br><span class="line">**判断字符**</span><br><span class="line"></span><br><span class="line">- 通常用on，where也可以，where可以作为on的补充</span><br><span class="line"> - join（连接的表）on （判断条件）——连接查询</span><br><span class="line"> - where——等值查询</span><br><span class="line">- 通常用法是先外连接join on出所有结果，再where筛选(这就是on on where 的正常流程，先由on连接，再由where筛选)</span><br><span class="line"></span><br><span class="line">其他：</span><br><span class="line"></span><br><span class="line">- as可以省略</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">注：在只能是有学号的考生考试的前提下，其实就无所谓右连接的说法了，因为成绩表中的学号是学生表学号的子集（符合实际），课程中的例子和以下两个例子就基于此</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">##### 两个进阶的例子：</span><br><span class="line"></span><br><span class="line">**①：查询缺考的同学**</span><br><span class="line"></span><br><span class="line">- 学生表中存放了学号、学生姓名</span><br><span class="line"></span><br><span class="line">- 成绩表中存放了学号、科目号、成绩</span><br><span class="line"></span><br><span class="line">现在要求结果是**“缺考的同学”**</span><br><span class="line"></span><br><span class="line">分析：</span><br><span class="line"></span><br><span class="line">缺考的同学的特征是什么→学生表中有中学生的学号，但成绩表中没有学生的学号</span><br><span class="line"></span><br><span class="line">step1：先找到所有学生</span><br><span class="line"></span><br><span class="line">~~~sql</span><br><span class="line">select s.StudentNo,StudentName,SubjectNo,StudentResult </span><br><span class="line">from student s</span><br><span class="line">left join result r</span><br><span class="line">on s.studentNo = r.studentNo;</span><br></pre></td></tr></table></figure></li>
</ul>
<p>step2：再筛选出没有成绩的学生即可</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">where</span> studentresult <span class="keyword">is</span> <span class="keyword">null</span>;</span><br></pre></td></tr></table></figure>
</blockquote>
<p><strong>②：三表连接</strong></p>
<ul>
<li><p>学生表中存放了学号、学生姓名</p>
</li>
<li><p>成绩表中存放了学号、科目号、成绩</p>
</li>
<li><p>科目表中存放了科目号、科目名</p>
</li>
</ul>
<p>现在要求结果具有：<strong>学号+科目名+成绩</strong></p>
<blockquote>
<p>分析：</p>
<p>这是一个三表连接的问题</p>
<p>学生表————（学号）————成绩表————（科目号）————科目表</p>
<p>遇到这种多表问题，采用逐个合并的方式，即由2得3，由3得4…….而不是一下就想着全写完</p>
<p>step1：连接两张表</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> s.StudentNo,r.StudentResult</span><br><span class="line"><span class="keyword">from</span> student s</span><br><span class="line"><span class="keyword">inner</span> <span class="keyword">join</span> <span class="keyword">result</span> r</span><br><span class="line"><span class="keyword">on</span> s.StudentNo <span class="operator">=</span> r.StudentNo</span><br></pre></td></tr></table></figure>

<p>到此为止，已经完成了两张表得连接，接下来继续连接成绩表和科目表（基于科目号相等）</p>
<p>step2：在两张表连接的基础上完成第三张表的连接</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> s.StudentNo,r.StudentResult,sb.SubjectName</span><br><span class="line"><span class="keyword">from</span> student s</span><br><span class="line"><span class="keyword">inner</span> <span class="keyword">join</span> <span class="keyword">result</span> r</span><br><span class="line"><span class="keyword">on</span> s.StudentNo <span class="operator">=</span> r.StudentNo</span><br><span class="line"><span class="keyword">inner</span> <span class="keyword">join</span> subject sb</span><br><span class="line"><span class="keyword">on</span> r.SubjectNo <span class="operator">=</span> sb.SubjectNo</span><br></pre></td></tr></table></figure>


</blockquote>
<h5 id="自连接："><a href="#自连接：" class="headerlink" title="自连接："></a>自连接：</h5><p>自己的表和自己的表连接，核心：</p>
<p>首先一定要明白，自连接的核心就是这个表的一列恰恰和这张表的另一列有关联</p>
<p>一个通俗易懂的例子：</p>
<blockquote>
<p>公司员工表里存着所有员工的信息，员工和员工之间存在上下级的关系，员工表里有一个字段专门存改员工的上级的姓名（也就是该表某一个员工的姓名），如果我想查看这么一种关系，那么使用自连接就可以了，这个表存在上级姓名的列对应这个表员工姓名的列。如果只查看员工信息，直接查询就行了；对与查询数据与数据的关联关系，自连接是首选。前提是：自连接必须该表的某一列的字段，和该表的另一个字段有关联才可以使用。</p>
<p>自连接查询的目的就是为了找到这种两列之间的关系！！</p>
</blockquote>
<p><strong>自连接详解：</strong></p>
<p>0、基准数据库：</p>
<p>现在有这么一张表：worker表</p>
<table>
<thead>
<tr>
<th>身份ID(ID)</th>
<th>组长的身份ID(superID)</th>
<th>员工姓名(name)</th>
</tr>
</thead>
<tbody><tr>
<td>2</td>
<td>1</td>
<td>A</td>
</tr>
<tr>
<td>3</td>
<td>1</td>
<td>B</td>
</tr>
<tr>
<td>4</td>
<td>3</td>
<td>C</td>
</tr>
<tr>
<td>5</td>
<td>1</td>
<td>D</td>
</tr>
<tr>
<td>6</td>
<td>3</td>
<td>E</td>
</tr>
<tr>
<td>7</td>
<td>5</td>
<td>F</td>
</tr>
<tr>
<td>8</td>
<td>2</td>
<td>G</td>
</tr>
</tbody></table>
<p>1、拆分成两张表来看：两张表其实都还是原表自身,只不过保留了部分记录而已</p>
<p>（组长和员工都是员工，只不过组长是特殊的员工，但员工ID是唯一的）</p>
<p>①组长表：</p>
<table>
<thead>
<tr>
<th>身份ID</th>
<th>组长身份ID</th>
<th>组长姓名</th>
</tr>
</thead>
<tbody><tr>
<td>2</td>
<td>1</td>
<td>A</td>
</tr>
<tr>
<td>3</td>
<td>1</td>
<td>B</td>
</tr>
<tr>
<td>5</td>
<td>1</td>
<td>D</td>
</tr>
</tbody></table>
<p>②成员表（由组长ID→组长姓名）</p>
<table>
<thead>
<tr>
<th>身份ID</th>
<th>组长身份ID</th>
<th>成员姓名</th>
</tr>
</thead>
<tbody><tr>
<td>4</td>
<td>3</td>
<td>C</td>
</tr>
<tr>
<td>6</td>
<td>3</td>
<td>E</td>
</tr>
<tr>
<td>7</td>
<td>5</td>
<td>F</td>
</tr>
<tr>
<td>8</td>
<td>2</td>
<td>G</td>
</tr>
</tbody></table>
<p>其实最初表拆开就是这两张表</p>
<p>员工通过组长ID来知道自己的组长是谁，我们会发现有几个特殊的记录，他们的组长ID是1，而员工ID中没有1，所以这几个记录没有组长了，他们自己是别人的组长，是最高的组长。</p>
<ul>
<li>此例中组长之上都没组长了，实际上组长之上可能还有组长，<strong>整体呈树状关系</strong></li>
</ul>
<blockquote>
<p>到此，自连接的目的和作用就出来了：<strong>找到这种组长——员工对应关系！</strong></p>
<p>即，结果应是类似如下的结果：</p>
<table>
<thead>
<tr>
<th>组长姓名</th>
<th>成员姓名</th>
</tr>
</thead>
<tbody><tr>
<td></td>
<td></td>
</tr>
</tbody></table>
</blockquote>
<p>好了，到此我们已经明白了自连接的是干嘛的，那么SQL语句该如何书写呢</p>
<p>首先，组长和成员，都是<strong>员工</strong>，那么我们上述结果表的两列都是<strong>原表的员工字段</strong>的部分记录，而一个表的一个字段只能查一次，所以把自己这张表用两次，也就是<strong>所谓的自己连接自己</strong></p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> super.name <span class="keyword">as</span> supername,sub.name <span class="keyword">as</span> subname</span><br><span class="line"><span class="keyword">from</span> worker <span class="keyword">as</span> super,worker <span class="keyword">as</span> sub</span><br><span class="line"><span class="keyword">where</span> super.ID <span class="operator">=</span> sub.superID;</span><br><span class="line"><span class="comment">-- 如果成员表中某条记录的组长ID=组长表中的身份ID,那么这俩组合起来就是要求的结果</span></span><br></pre></td></tr></table></figure>



<blockquote>
<p>补充一个自连接的例子</p>
<p>leetcode-181：超过经理收入的员工</p>
<p>Code：</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> e1.name Employee</span><br><span class="line"><span class="keyword">from</span> employee e1, employee e2</span><br><span class="line"><span class="keyword">where</span> e2.id <span class="operator">=</span> e1.managerid <span class="keyword">and</span> e2.salary<span class="operator">&lt;</span>e1.salary ;</span><br></pre></td></tr></table></figure>

<p><strong>总结：</strong></p>
<p>其实自连接不一定要是结果得到那张表的才能用自连接，只要是同一张表的两列产生关系的都可以用，</p>
<p>例如这里面我们就有一种冲动，想要</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> name <span class="keyword">from</span> employee <span class="keyword">where</span> salary <span class="operator">&gt;</span> managerid.salary </span><br></pre></td></tr></table></figure>

<ul>
<li>第一，managerid没法直接拿，用自连接再创建一个对象</li>
<li>managerid.salary 可以拆成两步 <strong>where e2.id = e1.managerid and e2.salary &lt; e1.salary</strong> </li>
</ul>
</blockquote>
<h4 id="3-5-分页和排序"><a href="#3-5-分页和排序" class="headerlink" title="3.5 分页和排序"></a>3.5 分页和排序</h4><ol>
<li>排序</li>
</ol>
<p>语法：<code>order by 字段名 asc/desc</code></p>
<p>asc代表增序、desc代表降序</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> studentresult </span><br><span class="line"><span class="keyword">FROM</span> <span class="keyword">result</span></span><br><span class="line"><span class="keyword">ORDER</span> <span class="keyword">BY</span> studentresult <span class="keyword">ASC</span>;</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>分页</li>
</ol>
<p>语法：<code>limit 起始值 长度</code>（起始值是包含的）</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> studentresult </span><br><span class="line"><span class="keyword">FROM</span> <span class="keyword">result</span></span><br><span class="line"><span class="keyword">ORDER</span> <span class="keyword">BY</span> studentresult <span class="keyword">ASC</span></span><br><span class="line">LIMIT <span class="number">0</span>,<span class="number">5</span>;</span><br><span class="line"><span class="comment">-- 取出成绩表的前五项</span></span><br></pre></td></tr></table></figure>

<p>注意</p>
<ul>
<li><p>limit从第0条记录开始</p>
</li>
<li><p>如果要模拟网页分页效果：每页10条记录</p>
<p>第一页 limit 0,10</p>
<p>第二页 limit 10, 10</p>
<p>第三页 limit 20,10</p>
<p>第K页 limit 10*(K-1),10</p>
</li>
</ul>
<h4 id="3-6-子查询"><a href="#3-6-子查询" class="headerlink" title="3.6 子查询"></a>3.6 子查询</h4><p>——其实子查询和联表是等价的，子查询和联表的关系，就像递归和迭代的关系一般</p>
<p>所谓的子查询就是嵌套查询，而且可以多层嵌套，无限嵌套，不过公司的规范要求是用联表查询代替子查询</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- 查询高等数学-1的所有考试的考试结果（学号、成绩），降序排列</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> `studentno`,`studentresult` </span><br><span class="line"><span class="keyword">FROM</span> <span class="keyword">result</span> r</span><br><span class="line"><span class="keyword">INNER</span> <span class="keyword">JOIN</span>  `subject` sub </span><br><span class="line"><span class="keyword">ON</span> r.`subjectno` <span class="operator">=</span> sub.`subjectno` </span><br><span class="line"><span class="comment">-- 通过innerjoin 相当于原先成绩表又有了考试科目名这一栏属性</span></span><br><span class="line"><span class="comment">-- 筛选出考试科目名为xxx即可</span></span><br><span class="line"><span class="keyword">WHERE</span> `subjectname` <span class="operator">=</span>  <span class="string">&#x27;高等数学-1&#x27;</span>;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">-- 对应的子查询</span></span><br><span class="line"><span class="comment">-- 思路：先把所有考试结果放在一起，然后再筛选出要求科目名对应的即可科目号</span></span><br><span class="line"><span class="comment">-- 和上一种思路区别在于，上面是直接筛名字，这里是找到另一张表中名字在这张表中对应的字段应该是何值</span></span><br><span class="line"><span class="keyword">SELECT</span> `studentno`,`studentresult` </span><br><span class="line"><span class="keyword">FROM</span> <span class="keyword">result</span> r</span><br><span class="line"><span class="keyword">WHERE</span> subjectno <span class="operator">=</span> (</span><br><span class="line">    <span class="keyword">SELECT</span> subjectno </span><br><span class="line">    <span class="keyword">FROM</span> `subject`</span><br><span class="line">    <span class="keyword">WHERE</span> subjectname <span class="operator">=</span> <span class="string">&#x27;高等数学-1&#x27;</span></span><br><span class="line">);</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<p><strong>一道例题的三种实现方式</strong></p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- 查询所有考了高等数学且分数不小于80分的学生的学号和姓名</span></span><br><span class="line"></span><br><span class="line"><span class="string">&#x27;==============内联派=================&#x27;</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> s.`studentno`,`studentname`</span><br><span class="line"><span class="keyword">FROM</span> student s</span><br><span class="line"><span class="keyword">INNER</span> <span class="keyword">JOIN</span> <span class="keyword">result</span> r </span><br><span class="line"><span class="keyword">ON</span> s.`studentno` <span class="operator">=</span> r.`studentno`</span><br><span class="line"><span class="keyword">INNER</span> <span class="keyword">JOIN</span> `subject` sub</span><br><span class="line"><span class="keyword">ON</span> r.`subjectno` <span class="operator">=</span> sub.`subjectno`</span><br><span class="line"><span class="keyword">WHERE</span> subjectname <span class="operator">=</span> <span class="string">&#x27;高等数学-1&#x27;</span> <span class="keyword">AND</span> studentresult <span class="operator">&gt;=</span> <span class="number">80</span>;</span><br><span class="line"><span class="comment">-- 每联一张表就相当于给这个记录多加了一个字段</span></span><br><span class="line"><span class="comment">-- 而这个字段基于两者相等的某个字段</span></span><br><span class="line"><span class="comment">-- 毕竟字段相等才能给你把另一张表的属性加上去，不然都不知道该给你加啥</span></span><br><span class="line"></span><br><span class="line"><span class="string">&#x27;==================综合派===================&#x27;</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> s.`studentno`,`studentname`</span><br><span class="line"><span class="keyword">FROM</span> student s</span><br><span class="line"><span class="keyword">INNER</span> <span class="keyword">JOIN</span> <span class="keyword">result</span> r </span><br><span class="line"><span class="keyword">ON</span> s.`studentno` <span class="operator">=</span> r.`studentno`</span><br><span class="line"><span class="keyword">WHERE</span> subjectno <span class="operator">=</span> (</span><br><span class="line">    <span class="keyword">SELECT</span> subjectno</span><br><span class="line">    <span class="keyword">FROM</span> `subject`</span><br><span class="line">    <span class="keyword">WHERE</span> subjectname <span class="operator">=</span> <span class="string">&#x27;高等数学-1&#x27;</span> </span><br><span class="line">) <span class="keyword">AND</span> studentresult <span class="operator">&gt;=</span> <span class="number">80</span>;</span><br><span class="line"></span><br><span class="line"><span class="string">&#x27;=============子查询（嵌套）派==============&#x27;</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> studentno, studentname </span><br><span class="line"><span class="keyword">FROM</span> student </span><br><span class="line"><span class="keyword">WHERE</span> studentno <span class="keyword">IN</span> (</span><br><span class="line">    <span class="keyword">SELECT</span> studentno </span><br><span class="line">    <span class="keyword">FROM</span> <span class="keyword">result</span></span><br><span class="line">    <span class="comment">-- 每条记录都是由 这三者组成的</span></span><br><span class="line">    <span class="comment">-- 通过限定另外两者就在所有记录中间接限定了studentno的范围</span></span><br><span class="line">    <span class="keyword">WHERE</span> studentresult <span class="operator">&gt;=</span><span class="number">80</span> <span class="keyword">AND</span> subjectno <span class="keyword">IN</span> (</span><br><span class="line">        <span class="keyword">SELECT</span> subjectno</span><br><span class="line">        <span class="keyword">FROM</span> `subject`</span><br><span class="line">        <span class="keyword">WHERE</span> subjectname <span class="operator">=</span> <span class="string">&#x27;高等数学-1&#x27;</span> </span><br><span class="line">    )</span><br><span class="line">);</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h4 id="3-7-分组和过滤"><a href="#3-7-分组和过滤" class="headerlink" title="3.7 分组和过滤"></a>3.7 分组和过滤</h4><p>如果要分多组，如性别里面分学校，只需要group by a，b即可</p>
<p>同时count（1）也会自动转换成统计每组的数量</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- 查询不同课程的平均分，最高分，最低分</span></span><br><span class="line"><span class="comment">-- 核心：（根据不同的课程分组）</span></span><br><span class="line"><span class="keyword">SELECT</span> subjectname, <span class="built_in">AVG</span>(`StudentResult`) 平均分, <span class="built_in">MAX</span>(`StudentResult`),<span class="built_in">MIN</span>(`StudentResult`)</span><br><span class="line"><span class="keyword">FROM</span> <span class="keyword">result</span> r</span><br><span class="line"><span class="keyword">INNER</span> <span class="keyword">JOIN</span> `subject` sub</span><br><span class="line"><span class="keyword">ON</span> r.`subjectno`<span class="operator">=</span>sub.`subjectno`</span><br><span class="line"><span class="keyword">GROUP</span> <span class="keyword">BY</span> r.`subjectno`<span class="comment">-- 通过什么字段</span></span><br><span class="line"><span class="keyword">HAVING</span> 平均分<span class="operator">&gt;</span><span class="number">80</span>;</span><br></pre></td></tr></table></figure>

<p>HAVING就是用来筛选分组后的结果</p>
<p>HAVING 和 WHERE 性质是一样的，前者用在分组之后，后者用在分组之前</p>
<h4 id="3-8-select完整语法"><a href="#3-8-select完整语法" class="headerlink" title="3.8 select完整语法"></a>3.8 select完整语法</h4><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span>[<span class="keyword">ALL</span><span class="operator">|</span><span class="keyword">DISTINCT</span><span class="operator">|</span>DISTINCTROW<span class="operator">|</span>TOP]</span><br><span class="line">&#123;<span class="operator">*</span> <span class="operator">|</span> talbe.<span class="operator">*</span> <span class="operator">|</span> [table.] field1 [<span class="keyword">AS</span> alias1][,[table.]field2[<span class="keyword">AS</span> alias2][,…]]&#125;</span><br><span class="line"><span class="keyword">FROM</span> tableexpression[,…][<span class="keyword">IN</span> externaldatabase]</span><br><span class="line">[<span class="keyword">left</span><span class="operator">|</span><span class="keyword">right</span><span class="operator">|</span><span class="keyword">inner</span> <span class="keyword">join</span> table_name] </span><br><span class="line">[<span class="keyword">on</span>]</span><br><span class="line">[<span class="keyword">WHERE</span>…]</span><br><span class="line">[<span class="keyword">GROUP</span> <span class="keyword">BY</span>…]</span><br><span class="line">[<span class="keyword">HAVING</span>…]</span><br><span class="line">[<span class="keyword">ORDER</span> <span class="keyword">BY</span>…]</span><br><span class="line">[LIMIT &#123;<span class="keyword">begin</span>&#125;,&#123;length&#125;] <span class="comment">--</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>on和where的区别？</p>
<h3 id="四、MySQL函数"><a href="#四、MySQL函数" class="headerlink" title="四、MySQL函数"></a>四、MySQL函数</h3><p>首先明确：Select不是只能查表，还可以查数，查运算</p>
<p>select 后面是表达式，表达式可以是字段、函数、etc</p>
<p>Select会返回一个结果，所以其他操作也用select</p>
<h4 id="1、常用函数"><a href="#1、常用函数" class="headerlink" title="1、常用函数"></a>1、常用函数</h4><p>sql也可以做一些常见的事情</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> <span class="built_in">abs</span>(<span class="number">-8</span>);<span class="comment">-- 返回绝对值</span></span><br><span class="line"><span class="keyword">select</span> rand();<span class="comment">-- 返回0-1之间的随机数</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">select</span> <span class="keyword">insert</span>(<span class="string">&#x27;一二三四五六七八九十&#x27;</span>,<span class="number">1</span>,<span class="number">2</span>,<span class="string">&#x27;超爱编程&#x27;</span>)</span><br><span class="line"><span class="string">&#x27;结果是  超爱编程三四五六七八九十&#x27;</span></span><br><span class="line"><span class="string">&#x27;即作用是把目标字符串的从下标1开始，长度为2的部分替换成后面的字符串&#x27;</span></span><br><span class="line"><span class="string">&#x27;注意：在这里下标从1开始，但limit中从0开始&#x27;</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> REPLACE(studentname,<span class="string">&#x27;李&#x27;</span>,<span class="string">&#x27;皮&#x27;</span>) <span class="keyword">FROM</span> student</span><br><span class="line"><span class="keyword">WHERE</span> studentname <span class="keyword">LIKE</span> <span class="string">&#x27;李%&#x27;</span>;</span><br><span class="line"><span class="comment">-- 查询姓李的，把结果中李换成皮</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> <span class="built_in">CURRENT_DATE</span>(); <span class="comment">-- 获取当前日期</span></span><br><span class="line"><span class="keyword">SELECT</span> NOW(); <span class="comment">-- 获取当前时间</span></span><br><span class="line"><span class="keyword">SELECT</span> <span class="built_in">LOCALTIME</span>(); <span class="comment">-- 本地时间</span></span><br><span class="line"><span class="keyword">SELECT</span> SYSDATE(); <span class="comment">-- 系统时间</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- 系统</span></span><br><span class="line"><span class="keyword">SELECT</span> <span class="built_in">SYSTEM_USER</span>();</span><br><span class="line"><span class="keyword">SELECT</span> <span class="keyword">USER</span>();</span><br><span class="line"><span class="keyword">SELECT</span> VERSION();</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h4 id="2、聚合函数"><a href="#2、聚合函数" class="headerlink" title="2、聚合函数"></a>2、聚合函数</h4><blockquote>
<p>写在前面：</p>
<ul>
<li>聚合函数：就是对某个字段的许多条记录组成的集合进行操作的函数</li>
<li>函数调用方式：FUNK_NAME（）</li>
</ul>
</blockquote>
<table>
<thead>
<tr>
<th>函数名称</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>COUNT</td>
<td>计数</td>
</tr>
<tr>
<td>SUM</td>
<td>求和</td>
</tr>
<tr>
<td>AVG</td>
<td>平均值</td>
</tr>
<tr>
<td>MAX</td>
<td>最大值</td>
</tr>
<tr>
<td>MIN</td>
<td>最小值</td>
</tr>
<tr>
<td>ROUND(xx,n)</td>
<td>四舍五入，保留n位小数</td>
</tr>
</tbody></table>
<p>例：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">select count(1) as male_num, round(avg(gpa),1) as avg_gpa from user_profile where gender = &#x27;male&#x27;;</span><br></pre></td></tr></table></figure>

<p>count可以配合distinct</p>
<p>count(distinct 字段)</p>
<blockquote>
<p>比较：COUNT(<em>)、COUNT(1)、*<em>COUNT(字段)</em></em></p>
<p>效果上：</p>
<p>效率上：</p>
<ul>
<li>列名不为主键，count1会比count列名快</li>
<li>如果没有主键，则count1的执行效率是最优的</li>
<li>列名为主键，count列名执行效率最优</li>
<li>如果表只有一个字段，则select count * 最优</li>
</ul>
</blockquote>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> <span class="built_in">COUNT</span>(`borndate`) <span class="keyword">FROM</span> student;  <span class="comment">-- count字段 忽略所有的null</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> <span class="built_in">COUNT</span>(<span class="operator">*</span>) <span class="keyword">FROM</span> student; <span class="comment">-- 不会忽略null，以第一列为基准</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> <span class="built_in">COUNT</span>(<span class="number">1</span>) <span class="keyword">FROM</span> student; <span class="comment">-- 不会忽略null，走遍所有列</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> <span class="built_in">SUM</span>(`StudentResult`) <span class="keyword">AS</span> 总和 <span class="keyword">FROM</span> <span class="keyword">result</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> <span class="built_in">AVG</span>(`StudentResult`) <span class="keyword">AS</span> 总和 <span class="keyword">FROM</span> <span class="keyword">result</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> <span class="built_in">MAX</span>(`StudentResult`) <span class="keyword">AS</span> 总和 <span class="keyword">FROM</span> <span class="keyword">result</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> <span class="built_in">MIN</span>(`StudentResult`) <span class="keyword">AS</span> 总和 <span class="keyword">FROM</span> <span class="keyword">result</span>;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h4 id="3、条件函数"><a href="#3、条件函数" class="headerlink" title="3、条件函数"></a>3、条件函数</h4><blockquote>
<p>条件函数和case都是对当前数据判断，如果符合条件就转为另一个值</p>
</blockquote>
<p>牛客sql26</p>
<p>if（x=n,a,b）表示如果x=n,则返回a，否则就是b了。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">select </span><br><span class="line">if (age&gt;=25,&#x27;25岁及以上&#x27;,&#x27;25岁以下&#x27;) as age_cut, -- 搭配as</span><br><span class="line">count(device_id) as number</span><br><span class="line">from user_profile</span><br><span class="line">group by age_cut;</span><br><span class="line"></span><br><span class="line">-- if可以嵌套</span><br><span class="line">select device_id, gender,</span><br><span class="line">if(age&lt;20,&#x27;20岁以下&#x27;,</span><br><span class="line">  if(age&lt;25,&#x27;20-24岁&#x27;,</span><br><span class="line">    if(age&gt;=25,&#x27;25岁及以上&#x27;,&#x27;其他&#x27;))) as age_cut</span><br><span class="line">from user_profile;</span><br></pre></td></tr></table></figure>

<h4 id="4、case分段"><a href="#4、case分段" class="headerlink" title="4、case分段"></a>4、case分段</h4><p>牛客sql27</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">select device_id, gender,</span><br><span class="line">case </span><br><span class="line">    when age&lt;20 then &#x27;20岁以下&#x27;</span><br><span class="line">    when age&lt;25 then &#x27;20-24岁&#x27;</span><br><span class="line">    when age&gt;=25 then &#x27;25岁及以上&#x27;</span><br><span class="line">    else &#x27;其他&#x27;</span><br><span class="line">end age_cut -- end 作为字段名</span><br><span class="line">from user_profile;</span><br></pre></td></tr></table></figure>

<h4 id="5、日期函数"><a href="#5、日期函数" class="headerlink" title="5、日期函数"></a>5、日期函数</h4><p>day()，获取日期</p>
<p>month()，获取月份</p>
<p>year()，获取年份</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">select day(date) as day, count(question_id) as question_cnt</span><br><span class="line">from question_practice_detail</span><br><span class="line">where year(date)=2021 and month(date) = 08</span><br><span class="line">group by day;</span><br></pre></td></tr></table></figure>

<h4 id="6、文本函数"><a href="#6、文本函数" class="headerlink" title="6、文本函数"></a>6、文本函数</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">select substring_index(profile,&#x27;,&#x27;,-1) gender, count(device_id) number</span><br><span class="line">from user_submit</span><br><span class="line">group by gender;</span><br></pre></td></tr></table></figure>

<p>1、LOCATE(substr , str )：返回子串 substr 在字符串 str 中第一次出现的位置，如果字符substr在字符串str中不存在，则返回0；</p>
<p>2、POSITION(substr IN str )：返回子串 substr 在字符串 str 中第一次出现的位置，如果字符substr在字符串str中不存在，与LOCATE函数作用相同；</p>
<p>3、LEFT(str, length)：从左边开始截取str，length是截取的长度；</p>
<p>4、RIGHT(str, length)：从右边开始截取str，length是截取的长度；</p>
<p>5、SUBSTRING_INDEX(str ,substr ,n)：返回字符substr在str中第n次出现位置之前的字符串;</p>
<blockquote>
<p>如果n是正数，那么就是从左往右数，第N个分隔符的左边的所有内容</p>
<p>如果n是负数，那么就是从右往左数，第N个分隔符的右边的所有内容</p>
</blockquote>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">- substring_index嵌套</span><br><span class="line">select </span><br><span class="line">substring_index(substring_index(profile,&#x27;,&#x27;,-2),&#x27;,&#x27;,1) as age,</span><br><span class="line">count(device_id) as number</span><br><span class="line">from user_submit</span><br><span class="line">group by age;</span><br></pre></td></tr></table></figure>

<p>6、SUBSTRING(str ,n ,m)：返回字符串str从第n个字符截取到第m个字符；</p>
<p>7、REPLACE(str, n, m)：将字符串str中的n字符替换成m字符；</p>
<p>8、LENGTH(str)：计算字符串str的长度。</p>
<h4 id="数据库级别的MD5加密（扩展）"><a href="#数据库级别的MD5加密（扩展）" class="headerlink" title="数据库级别的MD5加密（扩展）"></a>数据库级别的MD5加密（扩展）</h4><p>MD5：</p>
<p>增强算法复杂度和不可逆性</p>
<p>MD5不可逆，但相同的值的MD5是一样的（破解原理：把常见的可能的密码算md5，然后对比）</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> testmd5(</span><br><span class="line">    `id` <span class="type">INT</span>(<span class="number">4</span>) <span class="keyword">NOT</span> <span class="keyword">NULL</span>,</span><br><span class="line">    `name` <span class="type">VARCHAR</span>(<span class="number">20</span>) <span class="keyword">NOT</span> <span class="keyword">NULL</span>,</span><br><span class="line">    `pwd` <span class="type">VARCHAR</span>(<span class="number">100</span>) <span class="keyword">NOT</span> <span class="keyword">NULL</span>,</span><br><span class="line">    <span class="keyword">PRIMARY</span> KEY (`id`)</span><br><span class="line">)ENGINE <span class="operator">=</span> INNODB <span class="keyword">DEFAULT</span> CHARSET<span class="operator">=</span>utf8;</span><br><span class="line"></span><br><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> testmd5 <span class="keyword">VALUES</span>(<span class="number">1</span>,<span class="string">&#x27;zhangsan&#x27;</span>,<span class="string">&#x27;123456&#x27;</span>),</span><br><span class="line">(<span class="number">2</span>,<span class="string">&#x27;lisi&#x27;</span>,<span class="string">&#x27;123456&#x27;</span>),</span><br><span class="line">(<span class="number">3</span>,<span class="string">&#x27;wangwu&#x27;</span>,<span class="string">&#x27;123456&#x27;</span>),</span><br><span class="line">(<span class="number">4</span>,<span class="string">&#x27;zhaoliu&#x27;</span>,<span class="string">&#x27;123456&#x27;</span>);</span><br><span class="line"><span class="comment">-- 加密</span></span><br><span class="line">UPDATE testmd5 <span class="keyword">SET</span> pwd<span class="operator">=</span>MD5(pwd) <span class="keyword">WHERE</span> id<span class="operator">=</span><span class="number">1</span>;</span><br><span class="line"><span class="comment">-- 插入的时候加密</span></span><br><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> testmd5 <span class="keyword">VALUES</span>(<span class="number">5</span>,<span class="string">&#x27;xiaoming&#x27;</span>,MD5(<span class="string">&#x27;123456&#x27;</span>));</span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> <span class="operator">*</span> <span class="keyword">FROM</span> testmd5 <span class="keyword">WHERE</span> `name`<span class="operator">=</span><span class="string">&#x27;xiaoming&#x27;</span> <span class="keyword">AND</span> pwd<span class="operator">=</span>MD5(<span class="string">&#x27;123456&#x27;</span>);</span><br></pre></td></tr></table></figure>

<p>注：由于md5是不可逆加密，所以如果采取md5加密，检验的方法是，根据用户名找到对应的记录，把用户提供的密码加密后与数据库中的记录对比，如果相同则判定正确</p>
<h3 id="五、事务【TCL】"><a href="#五、事务【TCL】" class="headerlink" title="五、事务【TCL】"></a>五、事务【TCL】</h3><h4 id="5-0-INTRO"><a href="#5-0-INTRO" class="headerlink" title="5.0 INTRO"></a>5.0 INTRO</h4><p>事务分为：</p>
<ul>
<li>数据库事务【通常指的是这个】</li>
<li>分布式事务</li>
</ul>
<blockquote>
<p>背景：在执行sql语句时，某些业务要求一系列操作必须全部执行，而不能只执行一部分，例如最常见的转账操作：</p>
<ul>
<li>A 转给 B 100 元</li>
<li>B 收到 A 100 元</li>
</ul>
<p>那么，以上这个过程中的两个动作，必须全部执行，即<code>要么两个动作都执行，要么两个动作都不执行</code>。</p>
<p>如果因为某些原因，第一条语句成功了，第二条语句失败了，就<code>必须全部撤销</code></p>
</blockquote>
<p><strong>事务：</strong></p>
<p>把多条语句作为一个整体进行操作的功能，称为数据库的事务</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"># 开启事务</span><br><span class="line"><span class="keyword">start</span> transaction;</span><br><span class="line">sq1;</span><br><span class="line">sq2;</span><br><span class="line">...</span><br><span class="line"># 结束事务</span><br><span class="line"><span class="keyword">commit</span>;</span><br></pre></td></tr></table></figure>

<h4 id="5-1-事务的属性：ACID"><a href="#5-1-事务的属性：ACID" class="headerlink" title="5.1 事务的属性：ACID"></a><strong>5.1 事务的属性：ACID</strong></h4><p><strong>A：Atomic，原子性</strong>——若干条sql不可分割，要么全执行，要么不执行</p>
<p><strong>C：Consistent，一致性</strong>——事务完成后，所有的数据状态是一致的，即A账户少100，B账户多100，转账前后AB两人的钱数和不变</p>
<p><strong>I：Isolation：隔离</strong>——如果有多个事务（例如C也给B转钱）那么，每个事务必须与其他事务隔离</p>
<p><strong>D：Duration：持久性</strong>——即事务提交后，对数据库的修改是持久化的，即使数据库发生故障也不应该对数据产生影响；如果事务提交失败，事务的状态应当退回到事务的原始状态</p>
<h5 id="实现原理"><a href="#实现原理" class="headerlink" title="实现原理"></a>实现原理</h5><p>MySQL InnoDB 引擎使用 <strong>redo log(重做日志)</strong> 保证事务的<strong>持久性</strong>，使用 <strong>undo log(回滚日志)</strong> 来保证事务的<strong>原子性</strong>。</p>
<p>MySQL InnoDB 引擎通过 <strong>锁机制</strong>、<strong>MVCC</strong> 等手段来保证事务的隔离性（ 默认支持的隔离级别是 <strong><code>REPEATABLE-READ</code></strong> ）。</p>
<p>保证了事务的持久性、原子性、隔离性之后，一致性才能得到保障。</p>
<h4 id="5-2-事务的隔离级别"><a href="#5-2-事务的隔离级别" class="headerlink" title="5.2 事务的隔离级别"></a>5.2 事务的隔离级别</h4><h5 id="①：事务并发问题"><a href="#①：事务并发问题" class="headerlink" title="①：事务并发问题"></a>①：事务并发问题</h5><blockquote>
<p>对于两个并发执行的事务，如果涉及到操作同一条记录的时候，可能会发生由于并发操作带来的数据不一致问题</p>
</blockquote>
<p><strong>脏读（Dirty Read）：</strong></p>
<p>B事务读到了A事务尚未提交的数据，正是因为尚未提交，因此可能产生各种错误，常见的例子就是</p>
<blockquote>
<table>
<thead>
<tr>
<th>事务A</th>
<th>事务B</th>
</tr>
</thead>
<tbody><tr>
<td>将第一行从10改为99（未提交）</td>
<td>/</td>
</tr>
<tr>
<td>/</td>
<td>读取第一行，结果为99，用99操作</td>
</tr>
<tr>
<td>回滚</td>
<td>/</td>
</tr>
<tr>
<td>/</td>
<td>读取第一行，结果为10，用10操作</td>
</tr>
</tbody></table>
</blockquote>
<p><strong>不可重复读（Non Repeatable Read）：</strong></p>
<p>在一个事务内，多次读同一数据，在这个事务还没有结束时，如果另一个事务恰好修改了这个数据，那么，在第一个事务中，两次读取的数据就可能不一致【重点是多次读取同一个记录，发现记录增加or减少】</p>
<blockquote>
<table>
<thead>
<tr>
<th>事务A</th>
<th>事务B</th>
</tr>
</thead>
<tbody><tr>
<td>/</td>
<td>读取第一行，结果为10</td>
</tr>
<tr>
<td>修改第一行为99</td>
<td>/</td>
</tr>
<tr>
<td>提交</td>
<td>/</td>
</tr>
<tr>
<td>/</td>
<td>读取第一行，结果为99</td>
</tr>
</tbody></table>
</blockquote>
<ul>
<li>不可重复读和脏读的区别：脏读是读取到了尚未提交的值、不可重复是读到了两个不同的提交值</li>
</ul>
<p><strong>幻读（Phantom Read）：</strong></p>
<p>在一个事务中，查询某条记录，发现结果不存在，但是当试图更新这条数据时，竟然成功了，并且成功后再次读取，就能读到结果【读取到之前不存在的记录，像发生幻觉】</p>
<blockquote>
<table>
<thead>
<tr>
<th>事务A</th>
<th>事务B</th>
</tr>
</thead>
<tbody><tr>
<td></td>
<td>读取第99行，不存在</td>
</tr>
<tr>
<td>将99插入第99行</td>
<td></td>
</tr>
<tr>
<td>提交</td>
<td></td>
</tr>
<tr>
<td></td>
<td>读取第99行，结果为99【就像幻觉一样】</td>
</tr>
<tr>
<td></td>
<td>更新第99行为10</td>
</tr>
<tr>
<td></td>
<td>读取第99行，结果为10</td>
</tr>
</tbody></table>
</blockquote>
<p><strong>对于以上并发问题，mysql提供了四种隔离级别来应对，隔离级别的实现就是锁和MVCC</strong></p>
<h5 id="②：隔离级别【隔离级别是宏观笼统的概念，锁是微观概念】"><a href="#②：隔离级别【隔离级别是宏观笼统的概念，锁是微观概念】" class="headerlink" title="②：隔离级别【隔离级别是宏观笼统的概念，锁是微观概念】"></a>②：隔离级别【隔离级别是宏观笼统的概念，锁是微观概念】</h5><table>
<thead>
<tr>
<th>隔离级别</th>
<th>脏读</th>
<th>不可重复读</th>
<th>幻读</th>
</tr>
</thead>
<tbody><tr>
<td>Read Uncommitted【读取未提交】</td>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
</tr>
<tr>
<td>Read Committed【读取已提交】</td>
<td>-</td>
<td>Yes</td>
<td>Yes</td>
</tr>
<tr>
<td>Repeatable Read【可重复读】</td>
<td>-</td>
<td>-</td>
<td>Yes</td>
</tr>
<tr>
<td>Serializable【可串行化】</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
</tbody></table>
<p>注：yes表示可能出现的问题</p>
<p>读取未提交：允许读取尚未提交的数据</p>
<p>读取已提交：允许读取已提交的数据</p>
<p>可重复：确保对同一字段的多次读取结果一致</p>
<p>串行化：完全服从ACID，所有的事务依次逐个执行</p>
<p><strong>并不是无脑串行化，要考虑到效率问题</strong></p>
<p><strong>mysql的默认隔离级别：可重复读</strong></p>
<blockquote>
<p>补充：</p>
<p>InnoDB 存储引擎提供了对 XA 事务的支持，并通过 XA 事务来支持分布式事务的实现。分布式事务指的是允许多个独立的事务资源（transactional resources）参与到一个全局的事务中。事务资源通常是关系型数据库系统，但也可以是其他类型的资源。全局事务要求在其中的所有参与的事务要么都提交，要么都回滚，这对于事务原有的 ACID 要求又有了提高。<strong>另外，在使用分布式事务时，InnoDB 存储引擎的事务隔离级别必须设置为 SERIALIZABLE。</strong></p>
</blockquote>
<p>测试事务</p>
<p><strong>sql事务举例</strong></p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- sql默认开启事务自动提交，不提交是不能改变数据库中的数据的，写一条insert语句直接就交上去了</span></span><br><span class="line"><span class="keyword">SET</span> autocommit <span class="operator">=</span> <span class="number">0</span>; <span class="comment">-- 关闭 </span></span><br><span class="line"><span class="keyword">SET</span> autocommit <span class="operator">=</span> <span class="number">1</span>; <span class="comment">-- 开启</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- 开启事务的流程</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- 1、关闭自动提交</span></span><br><span class="line"><span class="keyword">SET</span> autocommit <span class="operator">=</span> <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 事务开启</span></span><br><span class="line"><span class="keyword">START</span> TRANSACTION <span class="comment">-- 从这条语句之后的sql都算在同一个事务内</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">INSERT</span> xx</span><br><span class="line"><span class="keyword">INSERT</span> xx</span><br><span class="line"></span><br><span class="line"><span class="comment">-- （事务成功）提交，持久化</span></span><br><span class="line"><span class="keyword">COMMIT</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- （事务失败）回滚：回到原来的样子</span></span><br><span class="line"><span class="keyword">ROLLBACK</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- 了解</span></span><br><span class="line"><span class="keyword">SAVEPOINT</span> 保存点名 <span class="comment">-- 设置一个事务的保存点</span></span><br><span class="line"><span class="keyword">ROLLBACK</span> <span class="keyword">TO</span> <span class="keyword">SAVEPOINT</span> 保存点名 <span class="comment">-- 回滚到保存点</span></span><br><span class="line"><span class="keyword">RELEASE</span> <span class="keyword">SAVEPOINT</span> 保存点名 <span class="comment">-- 撤销保存点 </span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>？？？</p>
<h3 id="六、索引"><a href="#六、索引" class="headerlink" title="六、索引"></a>六、索引</h3><blockquote>
<p>INTRO：</p>
<p>索引：帮助MySQL高效获取数据的数据结构，常见的索引结构有B树、B+树和Hash。</p>
<p>那么为什么要有索引：数据库的一个很大作用就是查找数据，查找数据就要根据某个（或某些个）字段来查找。</p>
<p>主键索引接解决了查找主键字段的问题，而查找其他字段的问题没解决，就需要建立索引（例如身份证作为主键，但是想查姓名，就需要建立姓名索引）</p>
</blockquote>
<p>索引为什么能提高性能——没索引前是顺序查找，有了索引后就可以有更高明的查找手段。【就比如折半查找就是比遍历一遍要快得多】</p>
<p><strong>优点：</strong>加快数据检索速度【本质是减少了检索的数据量】、通过创建唯一性索引，可以保证数据库表中数据的唯一性</p>
<p><strong>缺点：</strong>创建索引和维护索引浪费时间，当对表中数据频繁增删改时，索引也会频繁改变，降低SQL执行效率、需要占用物理空间</p>
<p><strong>索引在大数据量的时候有用，小数据量不一定能带来多大提升。</strong></p>
<h4 id="6-1-索引的分类"><a href="#6-1-索引的分类" class="headerlink" title="6.1 索引的分类"></a>6.1 索引的分类</h4><p>索引分为单列索引、组合索引和全文索引</p>
<p>1、单列索引：</p>
<p>单列索引即一个索引只包含单个列，一个表可以有多个单列索引</p>
<ul>
<li><p>主键索引 PRIMARY KEY</p>
<ul>
<li>是一种特殊的唯一索引，不允许有空值（特殊的唯一索引）</li>
</ul>
</li>
<li><p>唯一索引 UNIQUE KEY</p>
<ul>
<li>索引字段中的值必须是唯一的，但是允许为空值</li>
</ul>
</li>
<li><p>常规索引 KEY / INDEX （没名字的就是常规索引）</p>
<ul>
<li>MySQL中基本索引类型，没有什么限制，允许在定义索引的列中插入重复值和空值，纯粹为了查询数据更快一 点；可以利用KEY INDEX关键字来设置</li>
</ul>
</li>
</ul>
<p>2、组合索引</p>
<p>集合了表的多个字段的索引，只有在查询条件中使用了这些字段的左边字段时，索引才会被使用。</p>
<p>例如索引由（id/name/age）组合构成，那么查询时，用name/id/age组合就不会触发索引</p>
<p>3、全文索引</p>
<p>在大量数据的情况下模糊匹配，性能远优于like + %</p>
<ul>
<li>快速定位数据</li>
<li>不常使用</li>
</ul>
<h4 id="6-2-基础语法"><a href="#6-2-基础语法" class="headerlink" title="6.2 基础语法"></a>6.2 基础语法</h4><p>创建索引：</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- 创建表的时候创建</span></span><br><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> `student`(</span><br><span class="line">    <span class="keyword">PRIMARY</span> KEY (`studentno`),</span><br><span class="line">    <span class="keyword">UNIQUE</span> KEY `identitycard`(`identitycard`),</span><br><span class="line">    KEY `email` (`email`)</span><br><span class="line">)ENGINE<span class="operator">=</span>MYISAM <span class="keyword">DEFAULT</span> CHARSET<span class="operator">=</span>utf8;</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 创建完毕后，增加索引</span></span><br><span class="line"><span class="comment">-- 增加一个全文索引 索引名 （列名）</span></span><br><span class="line"><span class="keyword">ALTER</span> <span class="keyword">TABLE</span> `student` <span class="keyword">ADD</span> FULLTEXT studentname (studentname);</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 直接创建</span></span><br><span class="line"><span class="keyword">CREATE</span> INDEX index_name <span class="keyword">ON</span> tablename(<span class="keyword">column</span>);</span><br></pre></td></tr></table></figure>

<p>删除索引</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">DROP</span> INDEX index_name <span class="keyword">ON</span> tablename;</span><br></pre></td></tr></table></figure>

<p>使用索引</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- 显示所有的索引信息</span></span><br><span class="line"><span class="keyword">SHOW</span> INDEX <span class="keyword">FROM</span> student;</span><br><span class="line"></span><br><span class="line"><span class="comment">-- explain分析sql执行的状况</span></span><br><span class="line">EXPLAIN <span class="keyword">SELECT</span> <span class="operator">*</span> <span class="keyword">FROM</span> student ;  <span class="comment">-- 非全文索引</span></span><br><span class="line"></span><br><span class="line">EXPLAIN <span class="keyword">SELECT</span> <span class="operator">*</span> <span class="keyword">FROM</span> student <span class="keyword">WHERE</span> <span class="keyword">MATCH</span>(studentname) AGAINST (<span class="string">&#x27;李&#x27;</span>); </span><br></pre></td></tr></table></figure>



<p>要明白索引是一个数据结构，需要存储在内存中，当数据量很大的时候，建立索引也是一种资源消耗</p>
<p>有了索引，就无需遍历</p>
<p>索引在小数据量的时候，用户不大，但是在大数据的时候，却别十分明显</p>
<h4 id="6-2-测试索引"><a href="#6-2-测试索引" class="headerlink" title="6.2 测试索引"></a>6.2 测试索引</h4><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">CREATE</span> <span class="keyword">TABLE</span> `app_user`(</span><br><span class="line">    `id` <span class="type">BIGINT</span>(<span class="number">20</span>) UNSIGNED <span class="keyword">NOT</span> <span class="keyword">NULL</span> AUTO_INCREMENT,</span><br><span class="line">    `name` <span class="type">VARCHAR</span>(<span class="number">50</span>) <span class="keyword">DEFAULT</span> <span class="keyword">NULL</span>,</span><br><span class="line">    `email` <span class="type">VARCHAR</span>(<span class="number">50</span>) <span class="keyword">NOT</span> <span class="keyword">NULL</span>,</span><br><span class="line">    `phone` <span class="type">VARCHAR</span>(<span class="number">20</span>) <span class="keyword">DEFAULT</span> <span class="keyword">NULL</span>,</span><br><span class="line">    `gender` TINYINT(<span class="number">4</span>) UNSIGNED <span class="keyword">DEFAULT</span> <span class="number">0</span> ,</span><br><span class="line">    `password` <span class="type">VARCHAR</span>(<span class="number">100</span>) <span class="keyword">NOT</span> <span class="keyword">NULL</span> COMMENT <span class="string">&#x27;密码&#x27;</span>,</span><br><span class="line">    `age` TINYINT(<span class="number">4</span>) <span class="keyword">DEFAULT</span> <span class="number">0</span>  COMMENT <span class="string">&#x27;年龄&#x27;</span>,</span><br><span class="line">    `create_time` DATETIME <span class="keyword">DEFAULT</span> <span class="built_in">CURRENT_TIMESTAMP</span>,</span><br><span class="line">    `update_time` <span class="type">TIMESTAMP</span> <span class="keyword">NOT</span> <span class="keyword">NULL</span> <span class="keyword">DEFAULT</span> <span class="built_in">CURRENT_TIMESTAMP</span> <span class="keyword">ON</span> UPDATE <span class="built_in">CURRENT_TIMESTAMP</span>,</span><br><span class="line">    <span class="keyword">PRIMARY</span> KEY (`id`)</span><br><span class="line">) ENGINE<span class="operator">=</span>INNODB <span class="keyword">DEFAULT</span> CHARSET<span class="operator">=</span>utf8;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">-- 百万数据插入</span></span><br><span class="line"><span class="keyword">DROP</span> <span class="keyword">FUNCTION</span> IF <span class="keyword">EXISTS</span> mock_data; <span class="comment">-- 写函数之前必须要写，标志:$$</span></span><br><span class="line">DELIMITER $$</span><br><span class="line"><span class="keyword">CREATE</span> <span class="keyword">FUNCTION</span> mock_data()</span><br><span class="line"><span class="keyword">RETURNS</span> <span class="type">INT</span> <span class="comment">-- 注意returns，否则报错。</span></span><br><span class="line"><span class="keyword">DETERMINISTIC</span> <span class="comment">-- 8.0版本需要多这么一行</span></span><br><span class="line"><span class="keyword">BEGIN</span></span><br><span class="line">	<span class="keyword">DECLARE</span> num <span class="type">INT</span> <span class="keyword">DEFAULT</span> <span class="number">1000000</span>; <span class="comment">-- num 作为截止数字，定义为百万，</span></span><br><span class="line">	<span class="keyword">DECLARE</span> i <span class="type">INT</span> <span class="keyword">DEFAULT</span> <span class="number">0</span>;</span><br><span class="line">	WHILE i <span class="operator">&lt;</span> num DO</span><br><span class="line">        <span class="keyword">INSERT</span> <span class="keyword">INTO</span> app_user(`name`, `email`, `phone`, `gender`, `password`, `age`)</span><br><span class="line">        <span class="keyword">VALUES</span>(CONCAT(<span class="string">&#x27;用户&#x27;</span>, i),<span class="string">&#x27;965499224@qq.com&#x27;</span>, CONCAT(<span class="number">13</span>, <span class="built_in">FLOOR</span>((RAND()<span class="operator">*</span>(<span class="number">999999999</span><span class="number">-100000000</span>))<span class="operator">+</span><span class="number">100000000</span>)),<span class="built_in">FLOOR</span>(RAND()<span class="operator">*</span><span class="number">2</span>),UUID(), <span class="built_in">FLOOR</span>(RAND()<span class="operator">*</span><span class="number">100</span>));</span><br><span class="line">        <span class="keyword">SET</span> i <span class="operator">=</span> i <span class="operator">+</span> <span class="number">1</span>;</span><br><span class="line">	<span class="keyword">END</span> WHILE;</span><br><span class="line">	<span class="keyword">RETURN</span> i;</span><br><span class="line"><span class="keyword">END</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> mock_data();</span><br></pre></td></tr></table></figure>

<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> name <span class="keyword">from</span> app_user <span class="keyword">where</span> name <span class="operator">=</span> <span class="string">&#x27;用户9999&#x27;</span>; <span class="comment">-- 1.2s</span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- 命名格式：id_表名_字段名</span></span><br><span class="line"><span class="keyword">create</span> index id_app_user_name <span class="keyword">on</span> app_user(`name`)</span><br><span class="line"><span class="comment">-- 0.1s</span></span><br><span class="line"><span class="comment">-- </span></span><br><span class="line"><span class="keyword">select</span> <span class="operator">*</span> <span class="keyword">from</span> app_user <span class="keyword">where</span> name <span class="operator">=</span> <span class="string">&#x27;用户9999&#x27;</span>;</span><br></pre></td></tr></table></figure>



<p>索引原则</p>
<ul>
<li>索引不是越多越好</li>
<li>不要对经常变动的数据加索引</li>
<li>小数据量的表不需要加索引</li>
<li>索引一般加在常用来查询的字段上</li>
</ul>
<h4 id="6-3-索引的数据结构"><a href="#6-3-索引的数据结构" class="headerlink" title="6.3 索引的数据结构"></a>6.3 索引的数据结构</h4><p><a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_36381855/article/details/80011876?spm=1001.2101.3001.6650.3&utm_medium=distribute.pc_relevant.none-task-blog-2~default~CTRLIST~default-3.no_search_link&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2~default~CTRLIST~default-3.no_search_link">(31条消息) MySQL索引的数据结构以及算法原理_Zeus_龙的博客-CSDN博客_索引的数据结构</a></p>
<p>sql随机数是可以取到1的</p>
<h3 id="七、权限管理和备份【DCL】"><a href="#七、权限管理和备份【DCL】" class="headerlink" title="七、权限管理和备份【DCL】"></a>七、权限管理和备份【DCL】</h3><h4 id="7-1-权限管理："><a href="#7-1-权限管理：" class="headerlink" title="7.1 权限管理："></a>7.1 权限管理：</h4><p>本质：权限管理的本质是对mysql库的user表项的修改，主要有以下一些命令：</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- 创建用户</span></span><br><span class="line"><span class="keyword">CREATE</span> <span class="keyword">USER</span> mars IDENTIFIED <span class="keyword">BY</span> <span class="string">&#x27;123456&#x27;</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 修改密码（修改指定用户的密码）</span></span><br><span class="line"><span class="keyword">ALTER</span> <span class="keyword">USER</span> <span class="string">&#x27;mars&#x27;</span>@<span class="string">&#x27;%&#x27;</span> IDENTIFIED <span class="keyword">BY</span> <span class="string">&#x27;111111&#x27;</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 重命名</span></span><br><span class="line">RENAME <span class="keyword">USER</span> mars <span class="keyword">TO</span> mars1;</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 用户授权 权限 库.表</span></span><br><span class="line"><span class="keyword">GRANT</span> <span class="keyword">ALL</span> PRIVILEGES <span class="keyword">ON</span> <span class="operator">*</span>.<span class="operator">*</span> <span class="keyword">TO</span> mars1;</span><br><span class="line"><span class="comment">-- 除了给别人授权，其他都能干 </span></span><br><span class="line"></span><br><span class="line"><span class="comment">-- 查看权限</span></span><br><span class="line"><span class="keyword">SHOW</span> GRANTS <span class="keyword">FOR</span> <span class="string">&#x27;mars1&#x27;</span>@<span class="string">&#x27;%&#x27;</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">REVOKE</span> <span class="keyword">ALL</span> PRIVILEGES <span class="keyword">ON</span> <span class="operator">*</span>.<span class="operator">*</span> <span class="keyword">FROM</span> mars1;</span><br></pre></td></tr></table></figure>

<h4 id="7-2-数据库备份"><a href="#7-2-数据库备份" class="headerlink" title="7.2 数据库备份"></a>7.2 数据库备份</h4><p>备份的意义：</p>
<ul>
<li>保证重要数据不丢失</li>
<li>数据转移</li>
</ul>
<p>MySQL数据库备份的方式</p>
<ul>
<li>直接拷贝物理文件</li>
<li>在sqlyoug这种可视化工具中手动导出</li>
<li>命令行</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># mysqldump -h 主机 -u 用户名 -p 密码 数据库 表名 &gt; 物理磁盘位置/文件名 </span></span><br><span class="line">mysqldump -hlocalhost -uroot -p123456 school student &gt;E:/a.sql</span><br><span class="line"></span><br><span class="line"><span class="comment"># mysqldump -h 主机 -u 用户名 -p 密码 数据库 表名 [表名 表名] &gt; 物理磁盘位置/文件名 </span></span><br><span class="line">mysqldump -hlocalhost -uroot -p123456 school student result &gt;E:/a.sql</span><br><span class="line"></span><br><span class="line"><span class="comment"># mysqldump -h 主机 -u 用户名 -p 密码 数据库 &gt; 物理磁盘位置/文件名 </span></span><br><span class="line">mysqldump -hlocalhost -uroot -p123456 school &gt;E:/a.sql</span><br><span class="line"></span><br><span class="line"><span class="comment"># 导入</span></span><br><span class="line"><span class="comment"># 登录 mysql -u用户名 -p密码</span></span><br><span class="line">mysql -uroot -p123456</span><br><span class="line"><span class="comment"># 登录的情况下，切换到指定的数据库</span></span><br><span class="line">use school</span><br><span class="line"><span class="comment"># source 备份文件</span></span><br><span class="line"><span class="built_in">source</span> d:/a.sql</span><br><span class="line"><span class="comment"># 导入是指，如果数据库中没有该表，就导入，如果有，就不导</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h3 id="八：数据库设计"><a href="#八：数据库设计" class="headerlink" title="八：数据库设计"></a>八：数据库设计</h3><h4 id="8-0-数据库的设计步骤【概要】"><a href="#8-0-数据库的设计步骤【概要】" class="headerlink" title="8.0 数据库的设计步骤【概要】"></a>8.0 数据库的设计步骤【概要】</h4><p><strong>需求分析</strong> : 分析用户的需求，包括数据、功能和性能需求。</p>
<p><strong>概念结构设计</strong> : 主要采用 E-R 模型进行设计，包括画 E-R 图。</p>
<p><strong>逻辑结构设计</strong> : 通过将 E-R 图转换成表，实现从 E-R 模型到关系模型的转换。</p>
<p><strong>物理结构设计</strong> : 主要是为所设计的数据库选择合适的存储结构和存取路径。</p>
<p><strong>数据库实施</strong> : 包括编程、测试和试运行</p>
<p><strong>数据库的运行和维护</strong> : 系统的运行与数据库的日常维护。</p>
<h4 id="8-1-INTRO"><a href="#8-1-INTRO" class="headerlink" title="8.1 INTRO"></a>8.1 INTRO</h4><table>
<thead>
<tr>
<th>糟糕的数据库</th>
<th>良好的数据库</th>
</tr>
</thead>
<tbody><tr>
<td>数据冗余，浪费空间</td>
<td>避免重复字段</td>
</tr>
<tr>
<td>插入和删除麻烦（外键导致）</td>
<td>保证数据库的完整性</td>
</tr>
<tr>
<td>程序的性能差</td>
<td>易于开发系统</td>
</tr>
</tbody></table>
<p>软件开发中，关于数据库的设计</p>
<ul>
<li>分析需求：分析业务和需要处理的数据的需求</li>
<li>概要设计：设计关系图 ER图</li>
</ul>
<p>设计数据库的步骤——博客网站：</p>
<ul>
<li><p>收集信息，分析需求：</p>
<ul>
<li>用户表（用户账号密码、用户的个人信息，写博客，创建分类）</li>
<li>分类表（文章分类，谁创建的）</li>
<li>文章表（文章的信息）</li>
<li>友链表（友链信息）</li>
<li>自定义表（系统信息，关键字，或者一些主字段：例如博客的标题，后面会采用NoSQL来存储）</li>
<li>评论表</li>
<li>说说表（发表心情）</li>
<li></li>
</ul>
</li>
<li><p>建立实体（需求落地）</p>
</li>
<li><p>建立实体关系</p>
</li>
</ul>
<p>不用驼峰，用下划线</p>
<blockquote>
<p>评论表：</p>
<p>一个很好的自连接的例子</p>
<p>情景：评论区中某些评论是回复评论的，此时就可以设置一个父ID，用来记录该评论是回复哪条评论的，如果父ID是0/1（自己设置），就可以认为是针对文章的评论，反之是针对评论的评论</p>
</blockquote>
<blockquote>
<p>粉丝数：</p>
<p>粉丝数既可以通过mysql实现，也可以通过nosql实现，如果要通过mysql实现可以：</p>
<p>​    记录粉丝关系，如1000号用户关注了99号用户，然后统计出来有多少人关注了99号用户即可</p>
<p>​    当然：也可以用redis的nosql——json字符串实现</p>
</blockquote>
<h4 id="8-2-三大规范（范式）"><a href="#8-2-三大规范（范式）" class="headerlink" title="8.2 三大规范（范式）"></a>8.2 三大规范（范式）</h4><p>为什么要规范？</p>
<ul>
<li>信息重复</li>
<li>更新异常</li>
<li>插入异常<ul>
<li>无法正常显示信息（多个表中都有用户名，可能某次插入忘记插入到某个表中，就在对应页面丢失用户名）</li>
</ul>
</li>
<li>删除异常<ul>
<li>没删干净（经典情况就是删了文章还有标题、或者还剩下标题等等）</li>
</ul>
</li>
</ul>
<blockquote>
<p>三大范式——规范数据库</p>
</blockquote>
<p><strong>第一范式（1NF）：列不可再分</strong></p>
<ol>
<li><p>每一列的属性都是不可再分的属性值，确保每一列的原子性</p>
</li>
<li><p>两列的属性相近或相似或一样，尽量合并属性一样的列，确保不产生冗余数据</p>
</li>
</ol>
<p><strong>第二范式（2NF）：属性完全依赖主键</strong></p>
<p>每张表只描述一件事情——表中的每一列都必须与主键相关</p>
<p><img src="/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/image-20211118211243137.png" alt="image-20211118211243137"></p>
<p>此表的问题就在于：</p>
<p>在上图所示的情况中，同一个订单中可能包含不同的产品，因此主键必须是“订单号”和“产品号”联合组成，</p>
<p>但可以发现，产品数量、产品折扣、产品价格与“订单号”和“产品号”都相关，但是订单金额和订单时间仅与“订单号”相关，与“产品号”无关，</p>
<p>这样就不满足第二范式的要求，调整如下，需分成两个表：</p>
<p><img src="/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/image-20211118211350563.png" alt="image-20211118211350563"></p>
<p><strong>第三范式（3NF）：任何非主属性不依赖于其他非主属性</strong></p>
<p>第三范式需要确保数据表中的每一列数据都和主键直接相关，而不能间接相关。</p>
<p><img src="/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/image-20211118211526594.png" alt="image-20211118211526594"></p>
<p>上表中，所有属性都完全依赖于学号，所以满足第二范式，但是“班主任性别”和“班主任年龄”直接依赖的是“班主任姓名”，</p>
<p>而不是主键“学号”，所以需做如下调整：</p>
<p><img src="/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/image-20211118211544382.png" alt="image-20211118211544382"></p>
<h4 id="规范VS性能"><a href="#规范VS性能" class="headerlink" title="规范VS性能"></a>规范VS性能</h4><p>规范性和性能的问题，需要综合考虑</p>
<blockquote>
<p>阿里：关联查询的表不得超过三张表</p>
</blockquote>
<ul>
<li>考虑商业化的需求和目标（成本，用户体验！）数据库的性能更加重要</li>
<li>给某些表增加一些冗余的字段（可以减少多表查询的次数）</li>
<li>增加一些计算列（例如直接把count总数保存下来，避免每次都计算），从大数据量降低为小数据两的查询</li>
</ul>
<h3 id="九、JDBC"><a href="#九、JDBC" class="headerlink" title="九、JDBC"></a>九、JDBC</h3><h4 id="9-1-数据库驱动"><a href="#9-1-数据库驱动" class="headerlink" title="9.1 数据库驱动"></a>9.1 数据库驱动</h4><blockquote>
<p>在实际开发中，不同的工作可能要求用不同的数据库，而每个数据库能够在应用程序中使用的前提是具有数据库驱动，如图</p>
</blockquote>
<p><img src="/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/image-20211119084423716.png" alt="image-20211119084423716"></p>
<blockquote>
<p>而此时不同的数据库对应不同的驱动，那么应用程序如果对不同的驱动分别编程，将导致不同的代码，过度耦合。</p>
</blockquote>
<h4 id="9-2-JDBC（Java-Database-Connectivity）java数据库连接"><a href="#9-2-JDBC（Java-Database-Connectivity）java数据库连接" class="headerlink" title="9.2 JDBC（Java Database Connectivity）java数据库连接"></a>9.2 JDBC（Java Database Connectivity）java数据库连接</h4><p>SUN公司为了简化开发人员的（对数据库的统一）操作，提供了一个Java操作数据库的规范，具体实现由各个厂商去做。</p>
<p><img src="/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/image-20211119084812153.png" alt="image-20211119084812153"></p>
<p>有了JDBC以后，开发人员只需要专注于开发业务代码即可，实现与具体数据库的解耦</p>
<h4 id="9-3-第一个JDBC程序"><a href="#9-3-第一个JDBC程序" class="headerlink" title="9.3 第一个JDBC程序"></a>9.3 第一个JDBC程序</h4><ol>
<li>创建一个普通项目</li>
<li>导入数据库驱动</li>
<li>编写测试代码</li>
</ol>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.mars;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.sql.*;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Intro</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> <span class="keyword">throws</span> ClassNotFoundException, SQLException </span>&#123;</span><br><span class="line">        <span class="comment">// 1. 加载驱动</span></span><br><span class="line">      Class.forName(<span class="string">&quot;com.mysql.jdbc.Driver&quot;</span>);</span><br><span class="line">        </span><br><span class="line">        <span class="comment">// 2. 设置用户信息和url</span></span><br><span class="line">        String url = <span class="string">&quot;jdbc:mysql://localhost:3306/jdbcstudy?useUnicode=true&amp;characterEncoding=utf8&amp;useSSl=true&amp;serverTimezone=GMT%2B8&quot;</span>;</span><br><span class="line">        String username = <span class="string">&quot;root&quot;</span>;</span><br><span class="line">        String password = <span class="string">&quot;123456&quot;</span>;</span><br><span class="line">        <span class="comment">//使用Unicode编码方式，设定中文字符集为utf8</span></span><br><span class="line">        </span><br><span class="line">        <span class="comment">//前两步都是为了第三步做铺垫，即为了连接数据库</span></span><br><span class="line">        </span><br><span class="line">        <span class="comment">// 3. 连接数据库，得到数据库对象 connection</span></span><br><span class="line">        Connection connection = DriverManager.getConnection(url,username,password);</span><br><span class="line"></span><br><span class="line">        <span class="comment">// 4. 用来执行sql语句的载体，java万物皆对象，所以需要一个对象来执行sql语句</span></span><br><span class="line">        Statement statement = connection.createStatement();</span><br><span class="line">        <span class="comment">// 5. 执行对象执行sql语句，得到结果集</span></span><br><span class="line">        String sql = <span class="string">&quot;SELECT * FROM users&quot;</span>;</span><br><span class="line">        <span class="comment">//注意，statement对象执行语句只有executeQuery executeUpdate，没有增删，因为增删包含在更新里面了</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">//结果集中存放了查询的结果</span></span><br><span class="line">        ResultSet resultSet = statement.executeQuery(sql);</span><br><span class="line"></span><br><span class="line">        <span class="keyword">while</span>(resultSet.next())&#123;</span><br><span class="line">            System.out.println(<span class="string">&quot;id=&quot;</span> +resultSet.getObject(<span class="string">&quot;id&quot;</span>));</span><br><span class="line">            System.out.println(<span class="string">&quot;name=&quot;</span> +resultSet.getObject(<span class="string">&quot;NAME&quot;</span>));</span><br><span class="line">            System.out.println(<span class="string">&quot;pwd=&quot;</span> +resultSet.getObject(<span class="string">&quot;PASSWORD&quot;</span>));</span><br><span class="line">            System.out.println(<span class="string">&quot;email=&quot;</span> +resultSet.getObject(<span class="string">&quot;email&quot;</span>));</span><br><span class="line">            System.out.println(<span class="string">&quot;birth=&quot;</span> +resultSet.getObject(<span class="string">&quot;birthday&quot;</span>));</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">// 6.关闭资源</span></span><br><span class="line">        resultSet.close();</span><br><span class="line">        statement.close();</span><br><span class="line">        connection.close();</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><strong>总结流程：</strong></p>
<ol>
<li>加载驱动</li>
<li>设置主机地址，用户名，密码等</li>
<li>连接数据库，得到数据库对象</li>
<li>通过数据库对象的<code>createStatement</code>方法获取执行对象</li>
<li>设定sql语句并执行，获得结果</li>
<li>关闭资源</li>
</ol>
<p>三个对象：数据库对象，执行对象、结果集对象</p>
<p>对象解释：</p>
<p>DriverManager：</p>
<blockquote>
<p>Class.forName所做的工作是加载指定的class文件到java虚拟机的内存，加载class文件到内存的时候，该class文件的静态变量和静态初始化块是要执行的，玄机即在此。</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// connection代表数据库</span></span><br><span class="line"><span class="comment">// 数据库设置自动提交</span></span><br><span class="line"><span class="comment">// 事务提交</span></span><br><span class="line"><span class="comment">// 事务回滚</span></span><br><span class="line"></span><br><span class="line">connection.rollback();</span><br><span class="line">connection.commit();</span><br><span class="line">connection.setAutoCommit();</span><br></pre></td></tr></table></figure>

<p>URL：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">String url = <span class="string">&quot;jdbc:mysql://localhost:3306/jdbcstudy?useUnicode=true&amp;characterEncoding=utf8&amp;useSSl=true&amp;serverTimezone=GMT%2B8&quot;</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">//协议</span></span><br><span class="line"><span class="comment">//jdbc:mysql://主机地址:3306/数据库名?参数1&amp;参数2</span></span><br><span class="line"><span class="comment">//jdbc:oracle:thin:@localhost:1521:sid;</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>Statement：执行SQL</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">connection.prepareStatement(); <span class="comment">//编写sql</span></span><br><span class="line"></span><br><span class="line">statement.execute(sql);<span class="comment">// 返回是否执行成功</span></span><br><span class="line">statement.executeQuery(sql);<span class="comment">// 查询，返回ResultSet</span></span><br><span class="line">statement.executeUpdate(sql);<span class="comment">// 更新、插入、删除，返回一个受影响的行数，可以认为受影响的行数超过0就是成功</span></span><br><span class="line">    </span><br></pre></td></tr></table></figure>

<p>ResultSet查询结果集：封装所有查询结果</p>
<blockquote>
<p>ResultSet是一张表，即存储着许多行的记录，Result的经典方法next()就是拿到下一行记录，然后可以用 <strong>getObject(“字段名”)</strong> 方法获得该行记录的某个字段</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">resultSet.getObject();<span class="comment">//不知道对象类型时</span></span><br><span class="line">resultSet.getString();<span class="comment">//知道对象类型时</span></span><br><span class="line">resultSet.getRow();<span class="comment">//获得ResultSet的总行数</span></span><br><span class="line">resultSet.next();<span class="comment">// 下一个</span></span><br><span class="line">reslutSet.privious();<span class="comment">// 移动到前一行</span></span><br><span class="line">resultSet.beforeFirst();<span class="comment">// 移动到最前面</span></span><br><span class="line">resultSet.afterLast();<span class="comment">// 移动到最后面</span></span><br><span class="line">resultSet.absolute(row);<span class="comment">// 移动到指定行</span></span><br></pre></td></tr></table></figure>

<p>释放资源</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">resultSet.close();</span><br><span class="line">statement.close();</span><br><span class="line">connection.close();</span><br></pre></td></tr></table></figure>


<h5 id="提取工具类，重构JDBC流程："><a href="#提取工具类，重构JDBC流程：" class="headerlink" title="提取工具类，重构JDBC流程："></a><strong>提取工具类，重构JDBC流程：</strong></h5><blockquote>
<p>思考：</p>
<p>加载驱动、设定连接信息，关闭资源这三个步骤和sql业务无关，可以抽离出来作为一个工具类，在sql业务代码中只需要调用该类的这三个方法即可。</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">JdbcUtils</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> String driver = <span class="keyword">null</span>;</span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> String url = <span class="keyword">null</span>;</span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> String username = <span class="keyword">null</span>;</span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> String password = <span class="keyword">null</span>;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//直接在加载类的时候，把数据库驱动给加载了，相当于完成了基本的初始化工作，下次开启一个新的sql处理事务的时候，直接获取数据库连接就行了</span></span><br><span class="line">    <span class="comment">//try中声明的变量</span></span><br><span class="line">    <span class="keyword">static</span> &#123;</span><br><span class="line">        <span class="keyword">try</span>&#123;</span><br><span class="line">            InputStream in = JdbcUtils.class.getClassLoader().getResourceAsStream(<span class="string">&quot;db.properties&quot;</span>);</span><br><span class="line">            Properties properties = <span class="keyword">new</span> Properties();</span><br><span class="line">            properties.load((in));</span><br><span class="line">            <span class="comment">// 加载驱动</span></span><br><span class="line">            driver = properties.getProperty(<span class="string">&quot;driver&quot;</span>);</span><br><span class="line">            url = properties.getProperty(<span class="string">&quot;url&quot;</span>);</span><br><span class="line">            username = properties.getProperty(<span class="string">&quot;username&quot;</span>);</span><br><span class="line">            password = properties.getProperty(<span class="string">&quot;password&quot;</span>);</span><br><span class="line">            Class.forName(driver);</span><br><span class="line">        &#125;<span class="keyword">catch</span> (Exception e)&#123;</span><br><span class="line"></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//获取连接</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> Connection <span class="title">ReachConnection</span><span class="params">()</span></span>&#123;</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            <span class="keyword">return</span> DriverManager.getConnection(url,username,password);</span><br><span class="line">        &#125; <span class="keyword">catch</span> (SQLException e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">null</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//释放资源</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">release</span><span class="params">(Connection conn, Statement st, ResultSet rs)</span> <span class="keyword">throws</span> Exception</span>&#123;</span><br><span class="line">        <span class="keyword">if</span>(rs!=<span class="keyword">null</span>)&#123;</span><br><span class="line">            conn.close();</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span>(st!=<span class="keyword">null</span>)&#123;</span><br><span class="line">            st.close();</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span>(conn!=<span class="keyword">null</span>)&#123;</span><br><span class="line">            conn.close();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><strong>properties配置文件</strong></p>
<p>有了工具类以后，为了实现连接信息和工具类进一步解耦，可以创建一个properties配置文件，然后在工具类中读取配置文件即可</p>
<figure class="highlight properties"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">driver</span>=<span class="string">com.mysql.jdbc.Driver</span></span><br><span class="line"><span class="attr">url</span> = <span class="string">jdbc:mysql://localhost:3306/jdbcstudy?useUnicode=true&amp;characterEncoding=utf8&amp;useSSl=true&amp;serverTimezone=GMT%2B8</span></span><br><span class="line"><span class="attr">username</span> = <span class="string">root</span></span><br><span class="line"><span class="attr">password</span> = <span class="string">123456</span></span><br></pre></td></tr></table></figure>

<blockquote>
<p>现在有了以上工具类的抽离，编写sql业务代码时，只需要关注以下步骤：</p>
<ol>
<li>连接数据库，获得数据库对象</li>
<li>通过数据库对象获得statement执行对象</li>
<li>设定sql语句并执行</li>
</ol>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">TestQuery</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        Connection connection = <span class="keyword">null</span>;</span><br><span class="line">        Statement statement = <span class="keyword">null</span>;</span><br><span class="line">        ResultSet resultSet = <span class="keyword">null</span>;</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            <span class="comment">// 连接数据库（加载Jdbc工具类的时候自动按照配置文件设置信息）</span></span><br><span class="line">            connection = JdbcUtils.ReachConnection();</span><br><span class="line">            <span class="comment">// 获得执行对象</span></span><br><span class="line">            statement = connection.createStatement();</span><br><span class="line">			<span class="comment">// 设定sql</span></span><br><span class="line">            String sql = <span class="string">&quot;select * from users;&quot;</span>;</span><br><span class="line">            <span class="comment">//执行sql</span></span><br><span class="line">            resultSet = statement.executeQuery(sql);</span><br><span class="line">            <span class="keyword">while</span>(resultSet.next())&#123;</span><br><span class="line">                System.out.println(resultSet.getString(<span class="string">&quot;id&quot;</span>));</span><br><span class="line">            &#125;</span><br><span class="line">        &#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125; <span class="keyword">finally</span> &#123;</span><br><span class="line">            <span class="keyword">try</span> &#123;</span><br><span class="line">                JdbcUtils.release(connection,statement,resultSet);</span><br><span class="line">            &#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">                e.printStackTrace();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<h4 id="9-4-详解statement对象"><a href="#9-4-详解statement对象" class="headerlink" title="9.4 详解statement对象"></a>9.4 详解statement对象</h4><blockquote>
<p>JDBC中的statement对象用于向数据库发送sql语句</p>
</blockquote>
<p>statement对象有三个常用方法，包括</p>
<ol>
<li>execute：所有操作都可以执行，但是效率会低一些</li>
<li>executeUpdate：增、删、改</li>
<li>executeQuery：查</li>
</ol>
<h4 id="9-5-SQL注入"><a href="#9-5-SQL注入" class="headerlink" title="9.5 SQL注入"></a>9.5 SQL注入</h4><blockquote>
<p>假设一个登录业务的sql代码如下：</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">String sql = <span class="string">&quot;select * from users where `name` = &#x27;&quot;</span> + username + <span class="string">&quot;&#x27; and `PASSWORD`= &#x27;&quot;</span>+password+<span class="string">&quot;&#x27;;&quot;</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">//传入用户名和密码之后，sql代码会变成如下</span></span><br><span class="line">select * from users where `name` = <span class="string">&#x27;mars&#x27;</span> and `PASSWORD`=<span class="string">&#x27;123456&#x27;</span>;</span><br></pre></td></tr></table></figure>

<p><strong>而用户名和密码是用户输入的，</strong>基于此，我们可以输入name，password如下：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">用户名：<span class="string">&quot;&#x27;or&#x27;1=1&quot;</span></span><br><span class="line">密码：<span class="string">&quot;123&#x27;or &#x27;1=1&quot;</span></span><br></pre></td></tr></table></figure>

<p>按照以上输入，后台的sql代码会变成如下：</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> <span class="operator">*</span> <span class="keyword">from</span> users <span class="keyword">where</span> `name` <span class="operator">=</span> <span class="string">&#x27;&#x27;</span><span class="keyword">or</span><span class="string">&#x27;1=1&#x27;</span> <span class="keyword">and</span> `PASSWORD`<span class="operator">=</span> <span class="string">&#x27;123&#x27;</span> <span class="keyword">or</span> <span class="string">&#x27;1=1&#x27;</span>;</span><br></pre></td></tr></table></figure>

<p>而这个判断条件显然恒为true，因此，就可以获得users全部的数据</p>
<blockquote>
<p>以上，sql注入的核心原理是用户的不合理输入没有被正确过滤，java有一个可以屏蔽sql注入的对象：见9.6节</p>
</blockquote>
<h4 id="9-6-PreparedStatement对象"><a href="#9-6-PreparedStatement对象" class="headerlink" title="9.6 PreparedStatement对象"></a>9.6 PreparedStatement对象</h4><blockquote>
<p>prepareStatement就可以防止sql注入</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">PrepareSelect</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        Connection connection = <span class="keyword">null</span>;</span><br><span class="line">        PreparedStatement preparedStatement = <span class="keyword">null</span>;</span><br><span class="line">        ResultSet resultSet = <span class="keyword">null</span>;</span><br><span class="line"></span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            <span class="comment">//</span></span><br><span class="line">            connection = JdbcUtils.ReachConnection();</span><br><span class="line">			<span class="comment">//先写sql</span></span><br><span class="line">            String sql = <span class="string">&quot;select * from users where `id`&lt;?&quot;</span>;</span><br><span class="line">            <span class="comment">//得到执行对象的同时预编译sql</span></span><br><span class="line">            preparedStatement = connection.prepareStatement(sql);</span><br><span class="line">           <span class="comment">//再设置参数</span></span><br><span class="line">           preparedStatement.setInt(<span class="number">1</span>,<span class="number">5</span>);</span><br><span class="line">			<span class="comment">//再执行sql</span></span><br><span class="line">            resultSet = preparedStatement.executeQuery();</span><br><span class="line">            </span><br><span class="line">            <span class="keyword">while</span>(resultSet.next())&#123;</span><br><span class="line">                System.out.println(<span class="string">&quot;id&quot;</span>+resultSet.getInt(<span class="string">&quot;id&quot;</span>));</span><br><span class="line">                System.out.println(<span class="string">&quot;name&quot;</span>+resultSet.getString(<span class="string">&quot;name&quot;</span>));</span><br><span class="line">                System.out.println(<span class="string">&quot;password&quot;</span>+resultSet.getString(<span class="string">&quot;password&quot;</span>));</span><br><span class="line">                System.out.println(<span class="string">&quot;email&quot;</span>+resultSet.getString(<span class="string">&quot;email&quot;</span>));</span><br><span class="line">            &#125;</span><br><span class="line">        &#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125; <span class="keyword">finally</span> &#123;</span><br><span class="line">            <span class="keyword">try</span> &#123;</span><br><span class="line">                JdbcUtils.release(connection,preparedStatement,resultSet);</span><br><span class="line">            &#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">                e.printStackTrace();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>真正考究起来，prepareStatement只比statement多了一行设置参数值</p>
<blockquote>
<p>那么preparedStatement如何防止sql注入：</p>
<p>把传入进来的东西都当作字符。</p>
<p>原来用户输入`, ‘都是直接拼到字符串上去了，而现在用户输入会被再包裹一层双引号</p>
</blockquote>
<h4 id="9-7-使用IDEA连接数据库"><a href="#9-7-使用IDEA连接数据库" class="headerlink" title="9.7 使用IDEA连接数据库"></a>9.7 使用IDEA连接数据库</h4><blockquote>
<p>首先明白：不管是可视化工具还是代码，要想操作数据库，都要有驱动程序。</p>
</blockquote>
<p>而mysql的驱动程序就是<strong>mysql-connector-java</strong></p>
<p>可视化工具和项目代码中，要想操作数据库，都需要该驱动程序，才能操作数据库</p>
<blockquote>
<p>mybatis想要发挥作用，也需要数据库驱动程序，因为这是最底层的东西</p>
</blockquote>
<p>为了避免歧义，可以让项目版本和可视化工具版本保持一致。</p>
<p>正是因为导入了驱动程序文件，才能通过com.mysql.jdbc..driver点出来。</p>
<ul>
<li>注意驱动程序即可</li>
</ul>
<h4 id="9-8-JDBC事务"><a href="#9-8-JDBC事务" class="headerlink" title="9.8 JDBC事务"></a>9.8 JDBC事务</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">TestTransaction</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        Connection conn = <span class="keyword">null</span>;</span><br><span class="line">        PreparedStatement statement = <span class="keyword">null</span>;</span><br><span class="line">        ResultSet resultSet = <span class="keyword">null</span>;</span><br><span class="line"></span><br><span class="line">        <span class="keyword">int</span> money = <span class="number">200</span>;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            conn = JdbcUtils.ReachConnection();</span><br><span class="line">            <span class="comment">//关闭自动提交，自动会开启事务</span></span><br><span class="line">            conn.setAutoCommit(<span class="keyword">false</span>);<span class="comment">//开启事务</span></span><br><span class="line"></span><br><span class="line">            String sql = <span class="string">&quot;update account set money = money - ? where name = ? &quot;</span>;</span><br><span class="line">            statement = conn.prepareStatement(sql);</span><br><span class="line">            statement.setInt(<span class="number">1</span>,money);</span><br><span class="line">            statement.setString(<span class="number">2</span>,<span class="string">&quot;A&quot;</span>);</span><br><span class="line">            statement.executeUpdate();</span><br><span class="line"><span class="comment">// 写sql，预编译，传实参，执行</span></span><br><span class="line">            <span class="comment">//statement一次只能预编译一条sql语句</span></span><br><span class="line">            String sql1 = <span class="string">&quot;update account set money = money + ? where name = ? &quot;</span>;</span><br><span class="line">            statement = conn.prepareStatement(sql1);</span><br><span class="line">            statement.setInt(<span class="number">1</span>,money);</span><br><span class="line">            statement.setString(<span class="number">2</span>,<span class="string">&quot;B&quot;</span>);</span><br><span class="line">            statement.executeUpdate();</span><br><span class="line">            </span><br><span class="line">            conn.commit();</span><br><span class="line">            System.out.println(<span class="string">&quot;OK&quot;</span>);</span><br><span class="line"></span><br><span class="line">        &#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">            <span class="comment">//不用显示的定义回滚，事务失败会默认回滚</span></span><br><span class="line">            <span class="comment">//如果想要显示设置回滚，语法如下</span></span><br><span class="line">            <span class="keyword">try</span> &#123;</span><br><span class="line">                conn.rollback();</span><br><span class="line">            &#125; <span class="keyword">catch</span> (SQLException ex) &#123;</span><br><span class="line">                ex.printStackTrace();</span><br><span class="line">            &#125;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125; <span class="keyword">finally</span> &#123;</span><br><span class="line">            <span class="keyword">try</span> &#123;</span><br><span class="line">                JdbcUtils.release(conn,statement,resultSet);</span><br><span class="line">            &#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">                e.printStackTrace();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<blockquote>
<p>注：</p>
<p>conn.setAutoCommit(false)</p>
<p>关闭自动提交，则开启事务</p>
</blockquote>
<h4 id="9-9-池化技术——数据库连接池"><a href="#9-9-池化技术——数据库连接池" class="headerlink" title="9.9 池化技术——数据库连接池"></a>9.9 池化技术——数据库连接池</h4><p>数据库连接——执行——释放</p>
<p>连接——释放</p>
<p>池化技术：准备一些预先的资源，过来就连接预先准备好的（不用get connection了）</p>
<p>最小连接数：5、10、100、……（取决于常用连接数，两者相近即可）</p>
<p>最大连接数：业务最高承载上限（超过就得排队）</p>
<p>等待超时：超时即断</p>
<p>编写连接池，只需实现DataSource接口</p>
<blockquote>
<p>开源数据源实现</p>
</blockquote>
<p>DBCP、C3P0、Druid</p>
<p>使用了这些数据库连接池之后，我们在项目开发中就不要编写连接数据库的代码了</p>
<blockquote>
<p>DBCP实例：有了数据源之后，不用自己连接，只需要用数据源创建即可</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">JdbcUtils_DBCP</span> </span>&#123;</span><br><span class="line">        <span class="keyword">private</span> <span class="keyword">static</span> DataSource dataSource = <span class="keyword">null</span>;</span><br><span class="line">        <span class="keyword">static</span> &#123;</span><br><span class="line">            <span class="keyword">try</span>&#123;</span><br><span class="line">                InputStream in = com.mars.utils.JdbcUtils.class.getClassLoader().getResourceAsStream(<span class="string">&quot;dbcpconfig.properties&quot;</span>);</span><br><span class="line">                Properties properties = <span class="keyword">new</span> Properties();</span><br><span class="line">                properties.load((in));</span><br><span class="line">                <span class="comment">//创建数据源 工厂模式</span></span><br><span class="line">                dataSource = BasicDataSourceFactory.createDataSource(properties);</span><br><span class="line">            &#125;<span class="keyword">catch</span> (Exception e)&#123;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">//获取连接</span></span><br><span class="line">        <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> Connection <span class="title">ReachConnection</span><span class="params">()</span> <span class="keyword">throws</span> Exception</span>&#123;</span><br><span class="line">            <span class="keyword">return</span> dataSource.getConnection();</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">//释放资源</span></span><br><span class="line">        <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">release</span><span class="params">(Connection conn, Statement st, ResultSet rs)</span> <span class="keyword">throws</span> Exception</span>&#123;</span><br><span class="line">            <span class="keyword">if</span>(rs!=<span class="keyword">null</span>)&#123;</span><br><span class="line">                conn.close();</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span>(st!=<span class="keyword">null</span>)&#123;</span><br><span class="line">                st.close();</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span>(conn!=<span class="keyword">null</span>)&#123;</span><br><span class="line">                conn.close();</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">        &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<p>使用场景：？？？</p>
<p><a target="_blank" rel="noopener" href="https://www.pianshen.com/article/32511368085/">池化技术-数据库连接池 - 程序员大本营 (pianshen.com)</a></p>
<p>无论数据源是什么，DataSource接口不会变，方法不会改变</p>
<h3 id="十、MySQL面试"><a href="#十、MySQL面试" class="headerlink" title="十、MySQL面试"></a>十、MySQL面试</h3><h4 id="10-1-锁机制与InnoDB锁算法"><a href="#10-1-锁机制与InnoDB锁算法" class="headerlink" title="10.1 锁机制与InnoDB锁算法"></a>10.1 锁机制与InnoDB锁算法</h4><ul>
<li><p>MyISAM：表级锁</p>
</li>
<li><p>InnoDB：行级锁</p>
</li>
</ul>
<p>表级锁：对当前操作的表加锁，加锁粒度大，不会死锁，并发效率极低</p>
<p>行级锁：对当前操作的行加锁，加锁粒度小，可能出现死锁，并发效率高</p>
<p><strong>InnoDB的锁算法</strong></p>
<p>1、Record lock：记录锁，单个行记录上的锁</p>
<p>2、Gap lock：间隙锁，锁定一个范围，不包括记录自身</p>
<p>3、Next-key lock：临键锁，包含记录本身</p>
<h4 id="10-2-mysql缓存机制"><a href="#10-2-mysql缓存机制" class="headerlink" title="10.2 mysql缓存机制"></a>10.2 mysql缓存机制</h4><p>默认关闭，8以后没了</p>
<p><strong>开启缓存</strong></p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">query_cache_type<span class="operator">=</span><span class="number">1</span></span><br><span class="line">query_cache_size<span class="operator">=</span><span class="number">600000</span></span><br></pre></td></tr></table></figure>

<p><strong>查询缓存不命中的情况</strong></p>
<p>1）因此任何两个查询在任何字符上的不同都会导致缓存不命中。</p>
<p>2）此外，如果查询中包含任何用户自定义函数、存储函数、用户变量、临时表、MySQL 库中的系统表，其查询结果也不会被缓存。</p>
<p>3）<strong>缓存建立之后</strong>，MySQL 的查询缓存系统会跟踪查询中涉及的每张表，如果这些表（数据或结构）发生变化，那么和这张表相关的所有缓存数据都将失效。</p>
<p><strong>缓存虽然能够提升数据库的查询性能，但是缓存同时也带来了额外的开销，每次查询后都要做一次缓存操作，失效后还要销毁。</strong></p>
<p>如果是写密集型，请不要使用缓存</p>
<h4 id="10-4-一条sql语句是如何执行的"><a href="#10-4-一条sql语句是如何执行的" class="headerlink" title="10.4 一条sql语句是如何执行的"></a>10.4 一条sql语句是如何执行的</h4><h5 id="一、MySQL基本架构"><a href="#一、MySQL基本架构" class="headerlink" title="一、MySQL基本架构"></a>一、MySQL基本架构</h5><img src="/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/13526879-3037b144ed09eb88.png" alt="img" style="zoom: 67%;">

<p>MySql基本架构如图所示：</p>
<p>简单来说MySQL主要分为Server层和存储引擎层：</p>
<p><strong>Server层</strong></p>
<p><strong>连接器：</strong> 身份认证和权限相关(登录 MySQL 的时候)。【用户权限】</p>
<blockquote>
<p>只要连接不断开，权限就是此刻读到的权限，即使修改了。</p>
</blockquote>
<p><strong>查询缓存：</strong> 执行查询语句的时候，会先查询缓存（MySQL 8.0 版本后移除，因为这个功能不太实用）。</p>
<blockquote>
<p>MySQL 查询不建议使用缓存，因为查询缓存失效在实际业务场景中可能会非常频繁，假如你对一个表更新的话，这个表上的所有的查询缓存都会被清空。对于不经常更新的数据来说，使用缓存还是可以的。</p>
</blockquote>
<p><strong>分析器：</strong> 没有命中缓存的话，SQL 语句就会经过分析器，分析器说白了就是要先看你的 SQL 语句要干嘛，再检查你的 SQL 语句语法是否正确。</p>
<blockquote>
<p><strong>第一步，词法分析</strong>，一条 SQL 语句有多个字符串组成，首先要提取关键字，比如 select，提出查询的表，提出字段名，提出查询条件等等。做完这些操作后，就会进入第二步。</p>
<p><strong>第二步，语法分析</strong>，主要就是判断你输入的 sql 是否正确，是否符合 MySQL 的语法。</p>
</blockquote>
<p><strong>优化器：</strong> 按照 MySQL 认为最优的方案去执行。</p>
<blockquote>
<p>MySQL优化执行顺序，经过此步执行方案就确定了</p>
</blockquote>
<p><strong>执行器：</strong>【操作权限】</p>
<blockquote>
<p>校验该用户有没有权限，有的话调用引擎接口</p>
</blockquote>
<p><strong>存储引擎层</strong></p>
<p>主要负责数据的存储和读取，最常用的是InnoDB</p>
<h5 id="二、查询语句"><a href="#二、查询语句" class="headerlink" title="二、查询语句"></a>二、查询语句</h5><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> <span class="operator">*</span> <span class="keyword">from</span> tb_student A <span class="keyword">where</span> A.age<span class="operator">=</span><span class="string">&#x27;18&#x27;</span> <span class="keyword">and</span> A.name<span class="operator">=</span><span class="string">&#x27; 张三 &#x27;</span>;</span><br></pre></td></tr></table></figure>

<ul>
<li><p>先判断有没有权限，有权限的话，8.0以前会去查缓存，查到返回。查不到/8.0以后：</p>
</li>
<li><p>分析器得知操作是select，表名为tb_student ，条件是age为18，名字叫张三。</p>
</li>
<li><p>优化器：确定执行方案</p>
</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">a.先查询学生表中姓名为“张三”的学生，然后判断是否年龄是 18。</span><br><span class="line">b.先找出学生中年龄 18 岁的学生，然后再查询姓名为“张三”的学生。</span><br></pre></td></tr></table></figure>

<p>优化器根据算法优化决定哪种方案</p>
<ul>
<li>权限校验，没权限返回错误信息，有权限则调引擎接口</li>
</ul>
<h5 id="三、更新语句"><a href="#三、更新语句" class="headerlink" title="三、更新语句"></a>三、更新语句</h5><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">update tb_student A <span class="keyword">set</span> A.age<span class="operator">=</span><span class="string">&#x27;19&#x27;</span> <span class="keyword">where</span> A.name<span class="operator">=</span><span class="string">&#x27; 张三 &#x27;</span>;</span><br></pre></td></tr></table></figure>

<ul>
<li><p>先判断权限</p>
</li>
<li><p>【如果有缓存】去查询，【没缓存】走上面那一套，先查到数据【以执行器调用引擎查找为结束】</p>
</li>
<li><p><strong>执行器</strong>拿着查询的数据，把age改为19，调用引擎API接口写入这一行数据</p>
</li>
<li><p><strong>InnoDB引擎</strong>把数据保存到内存里，记录redo log，此时redo log进入prepare状态，告诉执行器，执行完了，随时可以提交</p>
</li>
<li><p><strong>执行器</strong>收到后记录binlog，调用引擎接口，将redo log提交</p>
</li>
<li><p>更新完成</p>
</li>
</ul>
<p>之所以两次日志，一是因为redo log是InnoDB自带的【所以InnoDB崩溃后才可恢复，MyISAM就不行】，而是解决数据一致性问题【？】</p>
<h4 id="10-5-InnoDB对MVCC的实现"><a href="#10-5-InnoDB对MVCC的实现" class="headerlink" title="10.5 InnoDB对MVCC的实现"></a>10.5 InnoDB对MVCC的实现</h4><h4 id="10-6-慢查询调优"><a href="#10-6-慢查询调优" class="headerlink" title="10.6 慢查询调优"></a>10.6 慢查询调优</h4><p>先开启慢查询日志，自己定义查询时间和记录位置</p>
<p>在my.ini配置文件中</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">long_query_time<span class="operator">=</span><span class="number">2</span></span><br><span class="line">slow_query_log<span class="operator">=</span><span class="keyword">On</span></span><br><span class="line">slow_query_log_file<span class="operator">=</span>&quot;xxx.log&quot;</span><br></pre></td></tr></table></figure>

<p>然后使用explain关键字查看sql的问题</p>
<p>主要关注type【连接类型】和key【索引】这两列</p>
<ul>
<li>然后判断情况</li>
</ul>
<p>看是不是索引失效，或者联表过多</p>
<p>通常将多个联表分为查找几个小表</p>
<h4 id="10-7-mysql持久化"><a href="#10-7-mysql持久化" class="headerlink" title="10.7 mysql持久化"></a>10.7 mysql持久化</h4><p>主要就是redo log 和 bin log及其操作</p>
<p>最左前缀匹配？</p>
<h4 id="10-8-mysql管理时间"><a href="#10-8-mysql管理时间" class="headerlink" title="10.8 mysql管理时间"></a>10.8 mysql管理时间</h4><h3 id="十一、MySQL并发控制"><a href="#十一、MySQL并发控制" class="headerlink" title="十一、MySQL并发控制"></a>十一、MySQL并发控制</h3><h4 id="11-1-更新丢失问题"><a href="#11-1-更新丢失问题" class="headerlink" title="11.1 更新丢失问题"></a>11.1 更新丢失问题</h4><blockquote>
<p>Mysql并发事务会引起更新丢失问题</p>
</blockquote>
<p>第一类丢失更新(回滚丢失，Lost update)。<br>在事务A期间，事务B对数据进行了更新；在事务A撤销之后，覆盖了事务B已经提交的数据。<br>SQL92没有定义这种现象，标准定义的所有隔离界别都不允许第一类丢失更新发生。</p>
<img src="/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/1415873-20190605112809343-999138139.png" alt="img" style="zoom: 67%;">

<p>第二类丢失更新(覆盖丢失/两次更新问题，Second lost update)。<br>在事务A期间，事务B对数据进行了更新；在事务A提交之后，覆盖了事务B已经提交的数据。<br>第二类丢失更新，实际上和不可重复读是同一种问题。</p>
<img src="/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/1415873-20190605112833419-1781156622.png" alt="img" style="zoom:67%;">

<p>这里我们主要讨论第二类更新丢失。</p>
<p>Mysql通过锁来解决更新丢失的问题，主要分为悲观锁和乐观锁两种</p>
<h4 id="11-2-悲观锁"><a href="#11-2-悲观锁" class="headerlink" title="11.2 悲观锁"></a>11.2 悲观锁</h4><p>要从InnoDB的MVCC谈起</p>
<p>MVCC分为快照读和当前读，普通的select是快照读，因此普通的select不会阻塞update，update也不会阻塞select</p>
<p>如果select加上修饰符，就会变成当前读，当前读分为共享锁【s锁】和排他锁【x锁】</p>
<p>悲观锁for update就是排他锁，由于update这个动作本身是排他锁，所以两者会排斥</p>
<p>悲观锁在事务完成就释放</p>
<p>为什么悲观锁和乐观锁可以控制</p>
<p>我们通常更新记录，需要两步，select出原来的，转化为实体类，更新，再update回去</p>
<p>产生问题的原因是，</p>
<p>读没有使用悲观锁，读到i=100【旧版本】，此时另一个事务正在修改，将i改为101，所以select出来的i为100，更新完还是101，出现问题</p>
<p>悲观锁之后，读与update互斥，此时就不会读到还没更新的数据</p>
<p>乐观锁则是：update本身是一个原子性的操作，如果版本号不同，就重试</p>
<p>悲观锁适合高并发，因为乐观锁在大量冲突时重试代价大</p>
<p><img src="/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/463931-20170331230304992-1130032942.png" alt="img"></p>

      

      
        <div class="page-reward">
          <a href="javascript:;" class="page-reward-btn tooltip-top">
            <div class="tooltip tooltip-east">
            <span class="tooltip-item">
              赏
            </span>
            <span class="tooltip-content">
              <span class="tooltip-text">
                <span class="tooltip-inner">
                  <p class="reward-p"><i class="icon icon-quo-left"></i>谢谢你请我吃糖果<i class="icon icon-quo-right"></i></p>
                  <div class="reward-box">
                    
                    
                  </div>
                </span>
              </span>
            </span>
          </div>
          </a>
        </div>
      
    </div>
    <div class="article-info article-info-index">
      
        <div class="article-pop-out tagcloud">
          <i class="icon-tuding"></i>
          <a class="article-tag-list-link color3">置顶</a>
        </div>
      
      
	<div class="article-tag tagcloud">
		<i class="icon-price-tags icon"></i>
		<ul class="article-tag-list">
			 
        		<li class="article-tag-list-item">
        			<a href="javascript:void(0)" class="js-tag article-tag-list-link color4">数据库</a>
        		</li>
      		
		</ul>
	</div>

      

      

      
        
<div class="share-btn share-icons tooltip-left">
  <div class="tooltip tooltip-east">
    <span class="tooltip-item">
      <a href="javascript:;" class="share-sns share-outer">
        <i class="icon icon-share"></i>
      </a>
    </span>
    <span class="tooltip-content">
      <div class="share-wrap">
        <div class="share-icons">
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="icon icon-weibo"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="icon icon-weixin"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="icon icon-qq"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="icon icon-douban"></i>
          </a>
          <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a>
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="icon icon-facebook"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="icon icon-twitter"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="icon icon-google"></i>
          </a>
        </div>
      </div>
    </span>
  </div>
</div>

<div class="page-modal wx-share js-wx-box">
    <a class="close js-modal-close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=http://marscarm.github.io/ee.io/2021/11/08/Mysql%E6%95%B0%E6%8D%AE%E5%BA%93/" alt="微信分享二维码">
    </div>
</div>

<div class="mask js-mask"></div>
      
      <div class="clearfix"></div>
    </div>
  </div>
</article>

  
<nav id="article-nav">
  
    <a href="/2021/11/09/git%E6%95%99%E7%A8%8B/" id="article-nav-newer" class="article-nav-link-wrap">
      <i class="icon-circle-left"></i>
      <div class="article-nav-title">
        
          git教程
        
      </div>
    </a>
  
  
    <a href="/2021/11/07/java%E6%B3%A8%E8%A7%A3%E4%B8%8E%E5%8F%8D%E5%B0%84/" id="article-nav-older" class="article-nav-link-wrap">
      <div class="article-nav-title">java注解与反射</div>
      <i class="icon-circle-right"></i>
    </a>
  
</nav>


<aside class="wrap-side-operation">
    <div class="mod-side-operation">
        
        <div class="jump-container" id="js-jump-container" style="display:none;">
            <a href="javascript:void(0)" class="mod-side-operation__jump-to-top">
                <i class="icon-font icon-back"></i>
            </a>
            <div id="js-jump-plan-container" class="jump-plan-container" style="top: -11px;">
                <i class="icon-font icon-plane jump-plane"></i>
            </div>
        </div>
        
        
        <div class="toc-container tooltip-left">
            <i class="icon-font icon-category"></i>
            <div class="tooltip tooltip-east">
                <span class="tooltip-item">
                </span>
                <span class="tooltip-content">
                    <div class="toc-article">
                    <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link"><span class="toc-number">1.</span> <span class="toc-text"></span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%B3%E7%B3%BB%E5%9E%8B%E6%95%B0%E6%8D%AE%E5%BA%93%E2%80%94%E2%80%94MySql"><span class="toc-number">1.0.1.</span> <span class="toc-text">关系型数据库——MySql</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%9B%B6-1%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86"><span class="toc-number">1.0.2.</span> <span class="toc-text">零-1、数据库基础知识</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#0-1-%E6%95%B0%E6%8D%AE%E5%BA%93"><span class="toc-number">1.0.2.1.</span> <span class="toc-text">0.1 数据库</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#0-2-%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5"><span class="toc-number">1.0.2.2.</span> <span class="toc-text">0.2 基本概念</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#0-3-%E5%A4%96%E9%94%AE%E4%B8%8E%E7%BA%A7%E8%81%94"><span class="toc-number">1.0.2.3.</span> <span class="toc-text">0.3 外键与级联</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#0-4-ER%E5%9B%BE"><span class="toc-number">1.0.2.4.</span> <span class="toc-text">0.4 ER图</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%9B%B6-2%E3%80%81%E5%AD%97%E7%AC%A6%E9%9B%86"><span class="toc-number">1.0.3.</span> <span class="toc-text">零-2、字符集</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#0-1-%E5%AD%97%E7%AC%A6%E9%9B%86"><span class="toc-number">1.0.3.1.</span> <span class="toc-text">0.1 字符集</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#0-2-%E5%B8%B8%E8%A7%81%E7%9A%84%E5%AD%97%E7%AC%A6%E9%9B%86"><span class="toc-number">1.0.3.2.</span> <span class="toc-text">0.2 常见的字符集</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#0-3-MySql%E5%AD%97%E7%AC%A6%E9%9B%86"><span class="toc-number">1.0.3.3.</span> <span class="toc-text">0.3 MySql字符集</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%80%E3%80%81Intro"><span class="toc-number">1.0.4.</span> <span class="toc-text">一、Intro</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-1-%E4%B8%BA%E4%BB%80%E4%B9%88%E5%AD%A6%E4%B9%A0%E6%95%B0%E6%8D%AE%E5%BA%93"><span class="toc-number">1.0.4.1.</span> <span class="toc-text">1.1 为什么学习数据库</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#1-2-%E4%BB%80%E4%B9%88%E6%98%AF%E6%95%B0%E6%8D%AE%E5%BA%93"><span class="toc-number">1.0.4.2.</span> <span class="toc-text">1.2 什么是数据库</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#1-3-%E6%95%B0%E6%8D%AE%E5%BA%93%E5%88%86%E7%B1%BB"><span class="toc-number">1.0.4.3.</span> <span class="toc-text">1.3 数据库分类</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#1-4-MySQL"><span class="toc-number">1.0.4.4.</span> <span class="toc-text">1.4 MySQL</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#1-5-%E5%AE%89%E8%A3%85"><span class="toc-number">1.0.4.5.</span> <span class="toc-text">1.5 安装</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#1-6-%E7%AE%A1%E7%90%86%E8%BD%AF%E4%BB%B6%EF%BC%9ASQLyog"><span class="toc-number">1.0.4.6.</span> <span class="toc-text">1.6 管理软件：SQLyog</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#1-7-%E8%BF%9E%E6%8E%A5%E6%95%B0%E6%8D%AE%E5%BA%93"><span class="toc-number">1.0.4.7.</span> <span class="toc-text">1.7 连接数据库</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BA%8C%E3%80%81MySQL%E8%A1%A8%E7%AE%A1%E7%90%86"><span class="toc-number">1.0.5.</span> <span class="toc-text">二、MySQL表管理</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#2-0-%E6%95%B0%E6%8D%AE%E5%BA%93%E4%BA%94%E5%A4%A7%E8%AF%AD%E8%A8%80%EF%BC%9A"><span class="toc-number">1.0.5.1.</span> <span class="toc-text">2.0 数据库五大语言：</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-1-DDL%E8%AF%AD%E8%A8%80%E6%93%8D%E4%BD%9C%E6%95%B0%E6%8D%AE%E5%BA%93"><span class="toc-number">1.0.5.2.</span> <span class="toc-text">2.1 DDL语言操作数据库</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-2-%E6%95%B0%E6%8D%AE%E5%BA%93%E7%9A%84%E5%88%97%E7%B1%BB%E5%9E%8B"><span class="toc-number">1.0.5.3.</span> <span class="toc-text">2.2 数据库的列类型</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%95%B0%E5%80%BC"><span class="toc-number">1.0.5.4.</span> <span class="toc-text">数值</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-3-%E6%95%B0%E6%8D%AE%E5%BA%93%E7%9A%84%E5%AD%97%E6%AE%B5%E5%B1%9E%E6%80%A7"><span class="toc-number">1.0.5.5.</span> <span class="toc-text">2.3 数据库的字段属性</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-4-%E5%88%9B%E5%BB%BA%E6%95%B0%E6%8D%AE%E5%BA%93%E8%A1%A8%EF%BC%88sql%EF%BC%89"><span class="toc-number">1.0.5.6.</span> <span class="toc-text">2.4 创建数据库表（sql）</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E6%A0%BC%E5%BC%8F"><span class="toc-number">1.0.5.6.1.</span> <span class="toc-text">格式</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-5-%E6%9F%A5%E7%9C%8B%E6%95%B0%E6%8D%AE%E5%BA%93%E5%BC%95%E6%93%8E"><span class="toc-number">1.0.5.7.</span> <span class="toc-text">2.5 查看数据库引擎</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-6-%E4%BF%AE%E6%94%B9%E5%92%8C%E5%88%A0%E9%99%A4%E8%A1%A8"><span class="toc-number">1.0.5.8.</span> <span class="toc-text">2.6 修改和删除表</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-7-%E5%88%A0%E9%99%A4%E8%A1%A8"><span class="toc-number">1.0.5.9.</span> <span class="toc-text">2.7 删除表</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%89%E3%80%81Mysql%E6%95%B0%E6%8D%AE%E7%AE%A1%E7%90%86"><span class="toc-number">1.0.6.</span> <span class="toc-text">三、Mysql数据管理</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#3-1-%E5%A4%96%E9%94%AE"><span class="toc-number">1.0.6.1.</span> <span class="toc-text">3.1 外键</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-2-DML%E8%AF%AD%E8%A8%80%EF%BC%88%E5%A2%9E%E5%88%A0%E6%94%B9%EF%BC%89"><span class="toc-number">1.0.6.2.</span> <span class="toc-text">3.2 DML语言（增删改）</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#3-2-1-%E6%B7%BB%E5%8A%A0"><span class="toc-number">1.0.6.2.1.</span> <span class="toc-text">3.2.1 添加</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#3-2-2-%E4%BF%AE%E6%94%B9"><span class="toc-number">1.0.6.2.2.</span> <span class="toc-text">3.2.2 修改</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#3-2-3-%E5%88%A0%E9%99%A4"><span class="toc-number">1.0.6.2.3.</span> <span class="toc-text">3.2.3 删除</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-3-DQL%E6%9F%A5%E8%AF%A2%E6%95%B0%E6%8D%AE%EF%BC%88%E6%95%B0%E6%8D%AE%E5%BA%93%E5%9B%9B%E5%A4%A7%E8%AF%AD%E8%A8%802%EF%BC%89"><span class="toc-number">1.0.6.3.</span> <span class="toc-text">3.3 DQL查询数据（数据库四大语言2）</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#3-3-1-DQL"><span class="toc-number">1.0.6.3.1.</span> <span class="toc-text">3.3.1 DQL</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#3-3-2-%E6%8C%87%E5%AE%9A%E6%9F%A5%E8%AF%A2%E6%89%8B%E6%AE%B5"><span class="toc-number">1.0.6.3.2.</span> <span class="toc-text">3.3.2 指定查询手段</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#3-3-3-where%E5%AD%90%E5%8F%A5%E8%A1%A8%E8%BE%BE%E5%BC%8F"><span class="toc-number">1.0.6.3.3.</span> <span class="toc-text">3.3.3 where子句表达式</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E6%A8%A1%E7%B3%8A%E6%9F%A5%E8%AF%A2%EF%BC%9A%E6%AF%94%E8%BE%83%E8%BF%90%E7%AE%97%E7%AC%A6"><span class="toc-number">1.0.6.3.4.</span> <span class="toc-text">模糊查询：比较运算符</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-4-%E8%BF%9E%E6%8E%A5%E6%9F%A5%E8%AF%A2"><span class="toc-number">1.0.6.4.</span> <span class="toc-text">3.4 连接查询</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E5%86%85%E8%BF%9E%E6%8E%A5%E4%B8%8E%E5%A4%96%E8%BF%9E%E6%8E%A5"><span class="toc-number">1.0.6.4.1.</span> <span class="toc-text">内连接与外连接</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E8%87%AA%E8%BF%9E%E6%8E%A5%EF%BC%9A"><span class="toc-number">1.0.6.4.2.</span> <span class="toc-text">自连接：</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-5-%E5%88%86%E9%A1%B5%E5%92%8C%E6%8E%92%E5%BA%8F"><span class="toc-number">1.0.6.5.</span> <span class="toc-text">3.5 分页和排序</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-6-%E5%AD%90%E6%9F%A5%E8%AF%A2"><span class="toc-number">1.0.6.6.</span> <span class="toc-text">3.6 子查询</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-7-%E5%88%86%E7%BB%84%E5%92%8C%E8%BF%87%E6%BB%A4"><span class="toc-number">1.0.6.7.</span> <span class="toc-text">3.7 分组和过滤</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-8-select%E5%AE%8C%E6%95%B4%E8%AF%AD%E6%B3%95"><span class="toc-number">1.0.6.8.</span> <span class="toc-text">3.8 select完整语法</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%9B%9B%E3%80%81MySQL%E5%87%BD%E6%95%B0"><span class="toc-number">1.0.7.</span> <span class="toc-text">四、MySQL函数</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1%E3%80%81%E5%B8%B8%E7%94%A8%E5%87%BD%E6%95%B0"><span class="toc-number">1.0.7.1.</span> <span class="toc-text">1、常用函数</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2%E3%80%81%E8%81%9A%E5%90%88%E5%87%BD%E6%95%B0"><span class="toc-number">1.0.7.2.</span> <span class="toc-text">2、聚合函数</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3%E3%80%81%E6%9D%A1%E4%BB%B6%E5%87%BD%E6%95%B0"><span class="toc-number">1.0.7.3.</span> <span class="toc-text">3、条件函数</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#4%E3%80%81case%E5%88%86%E6%AE%B5"><span class="toc-number">1.0.7.4.</span> <span class="toc-text">4、case分段</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#5%E3%80%81%E6%97%A5%E6%9C%9F%E5%87%BD%E6%95%B0"><span class="toc-number">1.0.7.5.</span> <span class="toc-text">5、日期函数</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#6%E3%80%81%E6%96%87%E6%9C%AC%E5%87%BD%E6%95%B0"><span class="toc-number">1.0.7.6.</span> <span class="toc-text">6、文本函数</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%95%B0%E6%8D%AE%E5%BA%93%E7%BA%A7%E5%88%AB%E7%9A%84MD5%E5%8A%A0%E5%AF%86%EF%BC%88%E6%89%A9%E5%B1%95%EF%BC%89"><span class="toc-number">1.0.7.7.</span> <span class="toc-text">数据库级别的MD5加密（扩展）</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BA%94%E3%80%81%E4%BA%8B%E5%8A%A1%E3%80%90TCL%E3%80%91"><span class="toc-number">1.0.8.</span> <span class="toc-text">五、事务【TCL】</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#5-0-INTRO"><span class="toc-number">1.0.8.1.</span> <span class="toc-text">5.0 INTRO</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#5-1-%E4%BA%8B%E5%8A%A1%E7%9A%84%E5%B1%9E%E6%80%A7%EF%BC%9AACID"><span class="toc-number">1.0.8.2.</span> <span class="toc-text">5.1 事务的属性：ACID</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86"><span class="toc-number">1.0.8.2.1.</span> <span class="toc-text">实现原理</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#5-2-%E4%BA%8B%E5%8A%A1%E7%9A%84%E9%9A%94%E7%A6%BB%E7%BA%A7%E5%88%AB"><span class="toc-number">1.0.8.3.</span> <span class="toc-text">5.2 事务的隔离级别</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E2%91%A0%EF%BC%9A%E4%BA%8B%E5%8A%A1%E5%B9%B6%E5%8F%91%E9%97%AE%E9%A2%98"><span class="toc-number">1.0.8.3.1.</span> <span class="toc-text">①：事务并发问题</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E2%91%A1%EF%BC%9A%E9%9A%94%E7%A6%BB%E7%BA%A7%E5%88%AB%E3%80%90%E9%9A%94%E7%A6%BB%E7%BA%A7%E5%88%AB%E6%98%AF%E5%AE%8F%E8%A7%82%E7%AC%BC%E7%BB%9F%E7%9A%84%E6%A6%82%E5%BF%B5%EF%BC%8C%E9%94%81%E6%98%AF%E5%BE%AE%E8%A7%82%E6%A6%82%E5%BF%B5%E3%80%91"><span class="toc-number">1.0.8.3.2.</span> <span class="toc-text">②：隔离级别【隔离级别是宏观笼统的概念，锁是微观概念】</span></a></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%AD%E3%80%81%E7%B4%A2%E5%BC%95"><span class="toc-number">1.0.9.</span> <span class="toc-text">六、索引</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#6-1-%E7%B4%A2%E5%BC%95%E7%9A%84%E5%88%86%E7%B1%BB"><span class="toc-number">1.0.9.1.</span> <span class="toc-text">6.1 索引的分类</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#6-2-%E5%9F%BA%E7%A1%80%E8%AF%AD%E6%B3%95"><span class="toc-number">1.0.9.2.</span> <span class="toc-text">6.2 基础语法</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#6-2-%E6%B5%8B%E8%AF%95%E7%B4%A2%E5%BC%95"><span class="toc-number">1.0.9.3.</span> <span class="toc-text">6.2 测试索引</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#6-3-%E7%B4%A2%E5%BC%95%E7%9A%84%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84"><span class="toc-number">1.0.9.4.</span> <span class="toc-text">6.3 索引的数据结构</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%83%E3%80%81%E6%9D%83%E9%99%90%E7%AE%A1%E7%90%86%E5%92%8C%E5%A4%87%E4%BB%BD%E3%80%90DCL%E3%80%91"><span class="toc-number">1.0.10.</span> <span class="toc-text">七、权限管理和备份【DCL】</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#7-1-%E6%9D%83%E9%99%90%E7%AE%A1%E7%90%86%EF%BC%9A"><span class="toc-number">1.0.10.1.</span> <span class="toc-text">7.1 权限管理：</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#7-2-%E6%95%B0%E6%8D%AE%E5%BA%93%E5%A4%87%E4%BB%BD"><span class="toc-number">1.0.10.2.</span> <span class="toc-text">7.2 数据库备份</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%AB%EF%BC%9A%E6%95%B0%E6%8D%AE%E5%BA%93%E8%AE%BE%E8%AE%A1"><span class="toc-number">1.0.11.</span> <span class="toc-text">八：数据库设计</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#8-0-%E6%95%B0%E6%8D%AE%E5%BA%93%E7%9A%84%E8%AE%BE%E8%AE%A1%E6%AD%A5%E9%AA%A4%E3%80%90%E6%A6%82%E8%A6%81%E3%80%91"><span class="toc-number">1.0.11.1.</span> <span class="toc-text">8.0 数据库的设计步骤【概要】</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#8-1-INTRO"><span class="toc-number">1.0.11.2.</span> <span class="toc-text">8.1 INTRO</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#8-2-%E4%B8%89%E5%A4%A7%E8%A7%84%E8%8C%83%EF%BC%88%E8%8C%83%E5%BC%8F%EF%BC%89"><span class="toc-number">1.0.11.3.</span> <span class="toc-text">8.2 三大规范（范式）</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%A7%84%E8%8C%83VS%E6%80%A7%E8%83%BD"><span class="toc-number">1.0.11.4.</span> <span class="toc-text">规范VS性能</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B9%9D%E3%80%81JDBC"><span class="toc-number">1.0.12.</span> <span class="toc-text">九、JDBC</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#9-1-%E6%95%B0%E6%8D%AE%E5%BA%93%E9%A9%B1%E5%8A%A8"><span class="toc-number">1.0.12.1.</span> <span class="toc-text">9.1 数据库驱动</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#9-2-JDBC%EF%BC%88Java-Database-Connectivity%EF%BC%89java%E6%95%B0%E6%8D%AE%E5%BA%93%E8%BF%9E%E6%8E%A5"><span class="toc-number">1.0.12.2.</span> <span class="toc-text">9.2 JDBC（Java Database Connectivity）java数据库连接</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#9-3-%E7%AC%AC%E4%B8%80%E4%B8%AAJDBC%E7%A8%8B%E5%BA%8F"><span class="toc-number">1.0.12.3.</span> <span class="toc-text">9.3 第一个JDBC程序</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E6%8F%90%E5%8F%96%E5%B7%A5%E5%85%B7%E7%B1%BB%EF%BC%8C%E9%87%8D%E6%9E%84JDBC%E6%B5%81%E7%A8%8B%EF%BC%9A"><span class="toc-number">1.0.12.3.1.</span> <span class="toc-text">提取工具类，重构JDBC流程：</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#9-4-%E8%AF%A6%E8%A7%A3statement%E5%AF%B9%E8%B1%A1"><span class="toc-number">1.0.12.4.</span> <span class="toc-text">9.4 详解statement对象</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#9-5-SQL%E6%B3%A8%E5%85%A5"><span class="toc-number">1.0.12.5.</span> <span class="toc-text">9.5 SQL注入</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#9-6-PreparedStatement%E5%AF%B9%E8%B1%A1"><span class="toc-number">1.0.12.6.</span> <span class="toc-text">9.6 PreparedStatement对象</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#9-7-%E4%BD%BF%E7%94%A8IDEA%E8%BF%9E%E6%8E%A5%E6%95%B0%E6%8D%AE%E5%BA%93"><span class="toc-number">1.0.12.7.</span> <span class="toc-text">9.7 使用IDEA连接数据库</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#9-8-JDBC%E4%BA%8B%E5%8A%A1"><span class="toc-number">1.0.12.8.</span> <span class="toc-text">9.8 JDBC事务</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#9-9-%E6%B1%A0%E5%8C%96%E6%8A%80%E6%9C%AF%E2%80%94%E2%80%94%E6%95%B0%E6%8D%AE%E5%BA%93%E8%BF%9E%E6%8E%A5%E6%B1%A0"><span class="toc-number">1.0.12.9.</span> <span class="toc-text">9.9 池化技术——数据库连接池</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8D%81%E3%80%81MySQL%E9%9D%A2%E8%AF%95"><span class="toc-number">1.0.13.</span> <span class="toc-text">十、MySQL面试</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#10-1-%E9%94%81%E6%9C%BA%E5%88%B6%E4%B8%8EInnoDB%E9%94%81%E7%AE%97%E6%B3%95"><span class="toc-number">1.0.13.1.</span> <span class="toc-text">10.1 锁机制与InnoDB锁算法</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#10-2-mysql%E7%BC%93%E5%AD%98%E6%9C%BA%E5%88%B6"><span class="toc-number">1.0.13.2.</span> <span class="toc-text">10.2 mysql缓存机制</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#10-4-%E4%B8%80%E6%9D%A1sql%E8%AF%AD%E5%8F%A5%E6%98%AF%E5%A6%82%E4%BD%95%E6%89%A7%E8%A1%8C%E7%9A%84"><span class="toc-number">1.0.13.3.</span> <span class="toc-text">10.4 一条sql语句是如何执行的</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E4%B8%80%E3%80%81MySQL%E5%9F%BA%E6%9C%AC%E6%9E%B6%E6%9E%84"><span class="toc-number">1.0.13.3.1.</span> <span class="toc-text">一、MySQL基本架构</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E4%BA%8C%E3%80%81%E6%9F%A5%E8%AF%A2%E8%AF%AD%E5%8F%A5"><span class="toc-number">1.0.13.3.2.</span> <span class="toc-text">二、查询语句</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E4%B8%89%E3%80%81%E6%9B%B4%E6%96%B0%E8%AF%AD%E5%8F%A5"><span class="toc-number">1.0.13.3.3.</span> <span class="toc-text">三、更新语句</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#10-5-InnoDB%E5%AF%B9MVCC%E7%9A%84%E5%AE%9E%E7%8E%B0"><span class="toc-number">1.0.13.4.</span> <span class="toc-text">10.5 InnoDB对MVCC的实现</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#10-6-%E6%85%A2%E6%9F%A5%E8%AF%A2%E8%B0%83%E4%BC%98"><span class="toc-number">1.0.13.5.</span> <span class="toc-text">10.6 慢查询调优</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#10-7-mysql%E6%8C%81%E4%B9%85%E5%8C%96"><span class="toc-number">1.0.13.6.</span> <span class="toc-text">10.7 mysql持久化</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#10-8-mysql%E7%AE%A1%E7%90%86%E6%97%B6%E9%97%B4"><span class="toc-number">1.0.13.7.</span> <span class="toc-text">10.8 mysql管理时间</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8D%81%E4%B8%80%E3%80%81MySQL%E5%B9%B6%E5%8F%91%E6%8E%A7%E5%88%B6"><span class="toc-number">1.0.14.</span> <span class="toc-text">十一、MySQL并发控制</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#11-1-%E6%9B%B4%E6%96%B0%E4%B8%A2%E5%A4%B1%E9%97%AE%E9%A2%98"><span class="toc-number">1.0.14.1.</span> <span class="toc-text">11.1 更新丢失问题</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#11-2-%E6%82%B2%E8%A7%82%E9%94%81"><span class="toc-number">1.0.14.2.</span> <span class="toc-text">11.2 悲观锁</span></a></li></ol></li></ol></li></ol></li></ol>
                    </div>
                </span>
            </div>
        </div>
        
    </div>
</aside>



  
  
  

  

  

  


          </div>
        </div>
      </div>
      <footer id="footer">
  <div class="outer">
    <div id="footer-info">
    	<div class="footer-left">
    		&copy; 2022 marscarm
    	</div>
      	<div class="footer-right">
      		<a href="http://hexo.io/" target="_blank">Hexo</a>  Theme <a href="https://github.com/litten/hexo-theme-yilia" target="_blank">Yilia</a> by Litten
      	</div>
    </div>
  </div>
</footer>
    </div>
    <script>
	var yiliaConfig = {
		mathjax: false,
		isHome: false,
		isPost: true,
		isArchive: false,
		isTag: false,
		isCategory: false,
		open_in_new: false,
		toc_hide_index: true,
		root: "/",
		innerArchive: true,
		showTags: false
	}
</script>

<script>!function(t){function n(e){if(r[e])return r[e].exports;var i=r[e]={exports:{},id:e,loaded:!1};return t[e].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}var r={};n.m=t,n.c=r,n.p="./",n(0)}([function(t,n,r){r(195),t.exports=r(191)},function(t,n,r){var e=r(3),i=r(52),o=r(27),u=r(28),c=r(53),f="prototype",a=function(t,n,r){var s,l,h,v,p=t&a.F,d=t&a.G,y=t&a.S,g=t&a.P,b=t&a.B,m=d?e:y?e[n]||(e[n]={}):(e[n]||{})[f],x=d?i:i[n]||(i[n]={}),w=x[f]||(x[f]={});d&&(r=n);for(s in r)l=!p&&m&&void 0!==m[s],h=(l?m:r)[s],v=b&&l?c(h,e):g&&"function"==typeof h?c(Function.call,h):h,m&&u(m,s,h,t&a.U),x[s]!=h&&o(x,s,v),g&&w[s]!=h&&(w[s]=h)};e.core=i,a.F=1,a.G=2,a.S=4,a.P=8,a.B=16,a.W=32,a.U=64,a.R=128,t.exports=a},function(t,n,r){var e=r(6);t.exports=function(t){if(!e(t))throw TypeError(t+" is not an object!");return t}},function(t,n){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(t,n){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,n){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(t,n){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,n,r){var e=r(126)("wks"),i=r(76),o=r(3).Symbol,u="function"==typeof o;(t.exports=function(t){return e[t]||(e[t]=u&&o[t]||(u?o:i)("Symbol."+t))}).store=e},function(t,n){var r={}.hasOwnProperty;t.exports=function(t,n){return r.call(t,n)}},function(t,n,r){var e=r(94),i=r(33);t.exports=function(t){return e(i(t))}},function(t,n,r){t.exports=!r(4)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,n,r){var e=r(2),i=r(167),o=r(50),u=Object.defineProperty;n.f=r(10)?Object.defineProperty:function(t,n,r){if(e(t),n=o(n,!0),e(r),i)try{return u(t,n,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[n]=r.value),t}},function(t,n,r){t.exports=!r(18)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,n,r){var e=r(14),i=r(22);t.exports=r(12)?function(t,n,r){return e.f(t,n,i(1,r))}:function(t,n,r){return t[n]=r,t}},function(t,n,r){var e=r(20),i=r(58),o=r(42),u=Object.defineProperty;n.f=r(12)?Object.defineProperty:function(t,n,r){if(e(t),n=o(n,!0),e(r),i)try{return u(t,n,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[n]=r.value),t}},function(t,n,r){var e=r(40)("wks"),i=r(23),o=r(5).Symbol,u="function"==typeof o;(t.exports=function(t){return e[t]||(e[t]=u&&o[t]||(u?o:i)("Symbol."+t))}).store=e},function(t,n,r){var e=r(67),i=Math.min;t.exports=function(t){return t>0?i(e(t),9007199254740991):0}},function(t,n,r){var e=r(46);t.exports=function(t){return Object(e(t))}},function(t,n){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,n,r){var e=r(63),i=r(34);t.exports=Object.keys||function(t){return e(t,i)}},function(t,n,r){var e=r(21);t.exports=function(t){if(!e(t))throw TypeError(t+" is not an object!");return t}},function(t,n){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,n){t.exports=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}},function(t,n){var r=0,e=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++r+e).toString(36))}},function(t,n){var r={}.hasOwnProperty;t.exports=function(t,n){return r.call(t,n)}},function(t,n){var r=t.exports={version:"2.4.0"};"number"==typeof __e&&(__e=r)},function(t,n){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,n,r){var e=r(11),i=r(66);t.exports=r(10)?function(t,n,r){return e.f(t,n,i(1,r))}:function(t,n,r){return t[n]=r,t}},function(t,n,r){var e=r(3),i=r(27),o=r(24),u=r(76)("src"),c="toString",f=Function[c],a=(""+f).split(c);r(52).inspectSource=function(t){return f.call(t)},(t.exports=function(t,n,r,c){var f="function"==typeof r;f&&(o(r,"name")||i(r,"name",n)),t[n]!==r&&(f&&(o(r,u)||i(r,u,t[n]?""+t[n]:a.join(String(n)))),t===e?t[n]=r:c?t[n]?t[n]=r:i(t,n,r):(delete t[n],i(t,n,r)))})(Function.prototype,c,function(){return"function"==typeof this&&this[u]||f.call(this)})},function(t,n,r){var e=r(1),i=r(4),o=r(46),u=function(t,n,r,e){var i=String(o(t)),u="<"+n;return""!==r&&(u+=" "+r+'="'+String(e).replace(/"/g,"&quot;")+'"'),u+">"+i+"</"+n+">"};t.exports=function(t,n){var r={};r[t]=n(u),e(e.P+e.F*i(function(){var n=""[t]('"');return n!==n.toLowerCase()||n.split('"').length>3}),"String",r)}},function(t,n,r){var e=r(115),i=r(46);t.exports=function(t){return e(i(t))}},function(t,n,r){var e=r(116),i=r(66),o=r(30),u=r(50),c=r(24),f=r(167),a=Object.getOwnPropertyDescriptor;n.f=r(10)?a:function(t,n){if(t=o(t),n=u(n,!0),f)try{return a(t,n)}catch(t){}if(c(t,n))return i(!e.f.call(t,n),t[n])}},function(t,n,r){var e=r(24),i=r(17),o=r(145)("IE_PROTO"),u=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=i(t),e(t,o)?t[o]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?u:null}},function(t,n){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on  "+t);return t}},function(t,n){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,n){t.exports={}},function(t,n){t.exports=!0},function(t,n){n.f={}.propertyIsEnumerable},function(t,n,r){var e=r(14).f,i=r(8),o=r(15)("toStringTag");t.exports=function(t,n,r){t&&!i(t=r?t:t.prototype,o)&&e(t,o,{configurable:!0,value:n})}},function(t,n,r){var e=r(40)("keys"),i=r(23);t.exports=function(t){return e[t]||(e[t]=i(t))}},function(t,n,r){var e=r(5),i="__core-js_shared__",o=e[i]||(e[i]={});t.exports=function(t){return o[t]||(o[t]={})}},function(t,n){var r=Math.ceil,e=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?e:r)(t)}},function(t,n,r){var e=r(21);t.exports=function(t,n){if(!e(t))return t;var r,i;if(n&&"function"==typeof(r=t.toString)&&!e(i=r.call(t)))return i;if("function"==typeof(r=t.valueOf)&&!e(i=r.call(t)))return i;if(!n&&"function"==typeof(r=t.toString)&&!e(i=r.call(t)))return i;throw TypeError("Can't convert object to primitive value")}},function(t,n,r){var e=r(5),i=r(25),o=r(36),u=r(44),c=r(14).f;t.exports=function(t){var n=i.Symbol||(i.Symbol=o?{}:e.Symbol||{});"_"==t.charAt(0)||t in n||c(n,t,{value:u.f(t)})}},function(t,n,r){n.f=r(15)},function(t,n){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},function(t,n){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on  "+t);return t}},function(t,n,r){var e=r(4);t.exports=function(t,n){return!!t&&e(function(){n?t.call(null,function(){},1):t.call(null)})}},function(t,n,r){var e=r(53),i=r(115),o=r(17),u=r(16),c=r(203);t.exports=function(t,n){var r=1==t,f=2==t,a=3==t,s=4==t,l=6==t,h=5==t||l,v=n||c;return function(n,c,p){for(var d,y,g=o(n),b=i(g),m=e(c,p,3),x=u(b.length),w=0,S=r?v(n,x):f?v(n,0):void 0;x>w;w++)if((h||w in b)&&(d=b[w],y=m(d,w,g),t))if(r)S[w]=y;else if(y)switch(t){case 3:return!0;case 5:return d;case 6:return w;case 2:S.push(d)}else if(s)return!1;return l?-1:a||s?s:S}}},function(t,n,r){var e=r(1),i=r(52),o=r(4);t.exports=function(t,n){var r=(i.Object||{})[t]||Object[t],u={};u[t]=n(r),e(e.S+e.F*o(function(){r(1)}),"Object",u)}},function(t,n,r){var e=r(6);t.exports=function(t,n){if(!e(t))return t;var r,i;if(n&&"function"==typeof(r=t.toString)&&!e(i=r.call(t)))return i;if("function"==typeof(r=t.valueOf)&&!e(i=r.call(t)))return i;if(!n&&"function"==typeof(r=t.toString)&&!e(i=r.call(t)))return i;throw TypeError("Can't convert object to primitive value")}},function(t,n,r){var e=r(5),i=r(25),o=r(91),u=r(13),c="prototype",f=function(t,n,r){var a,s,l,h=t&f.F,v=t&f.G,p=t&f.S,d=t&f.P,y=t&f.B,g=t&f.W,b=v?i:i[n]||(i[n]={}),m=b[c],x=v?e:p?e[n]:(e[n]||{})[c];v&&(r=n);for(a in r)(s=!h&&x&&void 0!==x[a])&&a in b||(l=s?x[a]:r[a],b[a]=v&&"function"!=typeof x[a]?r[a]:y&&s?o(l,e):g&&x[a]==l?function(t){var n=function(n,r,e){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(n);case 2:return new t(n,r)}return new t(n,r,e)}return t.apply(this,arguments)};return n[c]=t[c],n}(l):d&&"function"==typeof l?o(Function.call,l):l,d&&((b.virtual||(b.virtual={}))[a]=l,t&f.R&&m&&!m[a]&&u(m,a,l)))};f.F=1,f.G=2,f.S=4,f.P=8,f.B=16,f.W=32,f.U=64,f.R=128,t.exports=f},function(t,n){var r=t.exports={version:"2.4.0"};"number"==typeof __e&&(__e=r)},function(t,n,r){var e=r(26);t.exports=function(t,n,r){if(e(t),void 0===n)return t;switch(r){case 1:return function(r){return t.call(n,r)};case 2:return function(r,e){return t.call(n,r,e)};case 3:return function(r,e,i){return t.call(n,r,e,i)}}return function(){return t.apply(n,arguments)}}},function(t,n,r){var e=r(183),i=r(1),o=r(126)("metadata"),u=o.store||(o.store=new(r(186))),c=function(t,n,r){var i=u.get(t);if(!i){if(!r)return;u.set(t,i=new e)}var o=i.get(n);if(!o){if(!r)return;i.set(n,o=new e)}return o},f=function(t,n,r){var e=c(n,r,!1);return void 0!==e&&e.has(t)},a=function(t,n,r){var e=c(n,r,!1);return void 0===e?void 0:e.get(t)},s=function(t,n,r,e){c(r,e,!0).set(t,n)},l=function(t,n){var r=c(t,n,!1),e=[];return r&&r.forEach(function(t,n){e.push(n)}),e},h=function(t){return void 0===t||"symbol"==typeof t?t:String(t)},v=function(t){i(i.S,"Reflect",t)};t.exports={store:u,map:c,has:f,get:a,set:s,keys:l,key:h,exp:v}},function(t,n,r){"use strict";if(r(10)){var e=r(69),i=r(3),o=r(4),u=r(1),c=r(127),f=r(152),a=r(53),s=r(68),l=r(66),h=r(27),v=r(73),p=r(67),d=r(16),y=r(75),g=r(50),b=r(24),m=r(180),x=r(114),w=r(6),S=r(17),_=r(137),O=r(70),E=r(32),P=r(71).f,j=r(154),F=r(76),M=r(7),A=r(48),N=r(117),T=r(146),I=r(155),k=r(80),L=r(123),R=r(74),C=r(130),D=r(160),U=r(11),W=r(31),G=U.f,B=W.f,V=i.RangeError,z=i.TypeError,q=i.Uint8Array,K="ArrayBuffer",J="Shared"+K,Y="BYTES_PER_ELEMENT",H="prototype",$=Array[H],X=f.ArrayBuffer,Q=f.DataView,Z=A(0),tt=A(2),nt=A(3),rt=A(4),et=A(5),it=A(6),ot=N(!0),ut=N(!1),ct=I.values,ft=I.keys,at=I.entries,st=$.lastIndexOf,lt=$.reduce,ht=$.reduceRight,vt=$.join,pt=$.sort,dt=$.slice,yt=$.toString,gt=$.toLocaleString,bt=M("iterator"),mt=M("toStringTag"),xt=F("typed_constructor"),wt=F("def_constructor"),St=c.CONSTR,_t=c.TYPED,Ot=c.VIEW,Et="Wrong length!",Pt=A(1,function(t,n){return Tt(T(t,t[wt]),n)}),jt=o(function(){return 1===new q(new Uint16Array([1]).buffer)[0]}),Ft=!!q&&!!q[H].set&&o(function(){new q(1).set({})}),Mt=function(t,n){if(void 0===t)throw z(Et);var r=+t,e=d(t);if(n&&!m(r,e))throw V(Et);return e},At=function(t,n){var r=p(t);if(r<0||r%n)throw V("Wrong offset!");return r},Nt=function(t){if(w(t)&&_t in t)return t;throw z(t+" is not a typed array!")},Tt=function(t,n){if(!(w(t)&&xt in t))throw z("It is not a typed array constructor!");return new t(n)},It=function(t,n){return kt(T(t,t[wt]),n)},kt=function(t,n){for(var r=0,e=n.length,i=Tt(t,e);e>r;)i[r]=n[r++];return i},Lt=function(t,n,r){G(t,n,{get:function(){return this._d[r]}})},Rt=function(t){var n,r,e,i,o,u,c=S(t),f=arguments.length,s=f>1?arguments[1]:void 0,l=void 0!==s,h=j(c);if(void 0!=h&&!_(h)){for(u=h.call(c),e=[],n=0;!(o=u.next()).done;n++)e.push(o.value);c=e}for(l&&f>2&&(s=a(s,arguments[2],2)),n=0,r=d(c.length),i=Tt(this,r);r>n;n++)i[n]=l?s(c[n],n):c[n];return i},Ct=function(){for(var t=0,n=arguments.length,r=Tt(this,n);n>t;)r[t]=arguments[t++];return r},Dt=!!q&&o(function(){gt.call(new q(1))}),Ut=function(){return gt.apply(Dt?dt.call(Nt(this)):Nt(this),arguments)},Wt={copyWithin:function(t,n){return D.call(Nt(this),t,n,arguments.length>2?arguments[2]:void 0)},every:function(t){return rt(Nt(this),t,arguments.length>1?arguments[1]:void 0)},fill:function(t){return C.apply(Nt(this),arguments)},filter:function(t){return It(this,tt(Nt(this),t,arguments.length>1?arguments[1]:void 0))},find:function(t){return et(Nt(this),t,arguments.length>1?arguments[1]:void 0)},findIndex:function(t){return it(Nt(this),t,arguments.length>1?arguments[1]:void 0)},forEach:function(t){Z(Nt(this),t,arguments.length>1?arguments[1]:void 0)},indexOf:function(t){return ut(Nt(this),t,arguments.length>1?arguments[1]:void 0)},includes:function(t){return ot(Nt(this),t,arguments.length>1?arguments[1]:void 0)},join:function(t){return vt.apply(Nt(this),arguments)},lastIndexOf:function(t){return st.apply(Nt(this),arguments)},map:function(t){return Pt(Nt(this),t,arguments.length>1?arguments[1]:void 0)},reduce:function(t){return lt.apply(Nt(this),arguments)},reduceRight:function(t){return ht.apply(Nt(this),arguments)},reverse:function(){for(var t,n=this,r=Nt(n).length,e=Math.floor(r/2),i=0;i<e;)t=n[i],n[i++]=n[--r],n[r]=t;return n},some:function(t){return nt(Nt(this),t,arguments.length>1?arguments[1]:void 0)},sort:function(t){return pt.call(Nt(this),t)},subarray:function(t,n){var r=Nt(this),e=r.length,i=y(t,e);return new(T(r,r[wt]))(r.buffer,r.byteOffset+i*r.BYTES_PER_ELEMENT,d((void 0===n?e:y(n,e))-i))}},Gt=function(t,n){return It(this,dt.call(Nt(this),t,n))},Bt=function(t){Nt(this);var n=At(arguments[1],1),r=this.length,e=S(t),i=d(e.length),o=0;if(i+n>r)throw V(Et);for(;o<i;)this[n+o]=e[o++]},Vt={entries:function(){return at.call(Nt(this))},keys:function(){return ft.call(Nt(this))},values:function(){return ct.call(Nt(this))}},zt=function(t,n){return w(t)&&t[_t]&&"symbol"!=typeof n&&n in t&&String(+n)==String(n)},qt=function(t,n){return zt(t,n=g(n,!0))?l(2,t[n]):B(t,n)},Kt=function(t,n,r){return!(zt(t,n=g(n,!0))&&w(r)&&b(r,"value"))||b(r,"get")||b(r,"set")||r.configurable||b(r,"writable")&&!r.writable||b(r,"enumerable")&&!r.enumerable?G(t,n,r):(t[n]=r.value,t)};St||(W.f=qt,U.f=Kt),u(u.S+u.F*!St,"Object",{getOwnPropertyDescriptor:qt,defineProperty:Kt}),o(function(){yt.call({})})&&(yt=gt=function(){return vt.call(this)});var Jt=v({},Wt);v(Jt,Vt),h(Jt,bt,Vt.values),v(Jt,{slice:Gt,set:Bt,constructor:function(){},toString:yt,toLocaleString:Ut}),Lt(Jt,"buffer","b"),Lt(Jt,"byteOffset","o"),Lt(Jt,"byteLength","l"),Lt(Jt,"length","e"),G(Jt,mt,{get:function(){return this[_t]}}),t.exports=function(t,n,r,f){f=!!f;var a=t+(f?"Clamped":"")+"Array",l="Uint8Array"!=a,v="get"+t,p="set"+t,y=i[a],g=y||{},b=y&&E(y),m=!y||!c.ABV,S={},_=y&&y[H],j=function(t,r){var e=t._d;return e.v[v](r*n+e.o,jt)},F=function(t,r,e){var i=t._d;f&&(e=(e=Math.round(e))<0?0:e>255?255:255&e),i.v[p](r*n+i.o,e,jt)},M=function(t,n){G(t,n,{get:function(){return j(this,n)},set:function(t){return F(this,n,t)},enumerable:!0})};m?(y=r(function(t,r,e,i){s(t,y,a,"_d");var o,u,c,f,l=0,v=0;if(w(r)){if(!(r instanceof X||(f=x(r))==K||f==J))return _t in r?kt(y,r):Rt.call(y,r);o=r,v=At(e,n);var p=r.byteLength;if(void 0===i){if(p%n)throw V(Et);if((u=p-v)<0)throw V(Et)}else if((u=d(i)*n)+v>p)throw V(Et);c=u/n}else c=Mt(r,!0),u=c*n,o=new X(u);for(h(t,"_d",{b:o,o:v,l:u,e:c,v:new Q(o)});l<c;)M(t,l++)}),_=y[H]=O(Jt),h(_,"constructor",y)):L(function(t){new y(null),new y(t)},!0)||(y=r(function(t,r,e,i){s(t,y,a);var o;return w(r)?r instanceof X||(o=x(r))==K||o==J?void 0!==i?new g(r,At(e,n),i):void 0!==e?new g(r,At(e,n)):new g(r):_t in r?kt(y,r):Rt.call(y,r):new g(Mt(r,l))}),Z(b!==Function.prototype?P(g).concat(P(b)):P(g),function(t){t in y||h(y,t,g[t])}),y[H]=_,e||(_.constructor=y));var A=_[bt],N=!!A&&("values"==A.name||void 0==A.name),T=Vt.values;h(y,xt,!0),h(_,_t,a),h(_,Ot,!0),h(_,wt,y),(f?new y(1)[mt]==a:mt in _)||G(_,mt,{get:function(){return a}}),S[a]=y,u(u.G+u.W+u.F*(y!=g),S),u(u.S,a,{BYTES_PER_ELEMENT:n,from:Rt,of:Ct}),Y in _||h(_,Y,n),u(u.P,a,Wt),R(a),u(u.P+u.F*Ft,a,{set:Bt}),u(u.P+u.F*!N,a,Vt),u(u.P+u.F*(_.toString!=yt),a,{toString:yt}),u(u.P+u.F*o(function(){new y(1).slice()}),a,{slice:Gt}),u(u.P+u.F*(o(function(){return[1,2].toLocaleString()!=new y([1,2]).toLocaleString()})||!o(function(){_.toLocaleString.call([1,2])})),a,{toLocaleString:Ut}),k[a]=N?A:T,e||N||h(_,bt,T)}}else t.exports=function(){}},function(t,n){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},function(t,n,r){var e=r(21),i=r(5).document,o=e(i)&&e(i.createElement);t.exports=function(t){return o?i.createElement(t):{}}},function(t,n,r){t.exports=!r(12)&&!r(18)(function(){return 7!=Object.defineProperty(r(57)("div"),"a",{get:function(){return 7}}).a})},function(t,n,r){"use strict";var e=r(36),i=r(51),o=r(64),u=r(13),c=r(8),f=r(35),a=r(96),s=r(38),l=r(103),h=r(15)("iterator"),v=!([].keys&&"next"in[].keys()),p="keys",d="values",y=function(){return this};t.exports=function(t,n,r,g,b,m,x){a(r,n,g);var w,S,_,O=function(t){if(!v&&t in F)return F[t];switch(t){case p:case d:return function(){return new r(this,t)}}return function(){return new r(this,t)}},E=n+" Iterator",P=b==d,j=!1,F=t.prototype,M=F[h]||F["@@iterator"]||b&&F[b],A=M||O(b),N=b?P?O("entries"):A:void 0,T="Array"==n?F.entries||M:M;if(T&&(_=l(T.call(new t)))!==Object.prototype&&(s(_,E,!0),e||c(_,h)||u(_,h,y)),P&&M&&M.name!==d&&(j=!0,A=function(){return M.call(this)}),e&&!x||!v&&!j&&F[h]||u(F,h,A),f[n]=A,f[E]=y,b)if(w={values:P?A:O(d),keys:m?A:O(p),entries:N},x)for(S in w)S in F||o(F,S,w[S]);else i(i.P+i.F*(v||j),n,w);return w}},function(t,n,r){var e=r(20),i=r(100),o=r(34),u=r(39)("IE_PROTO"),c=function(){},f="prototype",a=function(){var t,n=r(57)("iframe"),e=o.length;for(n.style.display="none",r(93).appendChild(n),n.src="javascript:",t=n.contentWindow.document,t.open(),t.write("<script>document.F=Object<\/script>"),t.close(),a=t.F;e--;)delete a[f][o[e]];return a()};t.exports=Object.create||function(t,n){var r;return null!==t?(c[f]=e(t),r=new c,c[f]=null,r[u]=t):r=a(),void 0===n?r:i(r,n)}},function(t,n,r){var e=r(63),i=r(34).concat("length","prototype");n.f=Object.getOwnPropertyNames||function(t){return e(t,i)}},function(t,n){n.f=Object.getOwnPropertySymbols},function(t,n,r){var e=r(8),i=r(9),o=r(90)(!1),u=r(39)("IE_PROTO");t.exports=function(t,n){var r,c=i(t),f=0,a=[];for(r in c)r!=u&&e(c,r)&&a.push(r);for(;n.length>f;)e(c,r=n[f++])&&(~o(a,r)||a.push(r));return a}},function(t,n,r){t.exports=r(13)},function(t,n,r){var e=r(76)("meta"),i=r(6),o=r(24),u=r(11).f,c=0,f=Object.isExtensible||function(){return!0},a=!r(4)(function(){return f(Object.preventExtensions({}))}),s=function(t){u(t,e,{value:{i:"O"+ ++c,w:{}}})},l=function(t,n){if(!i(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!o(t,e)){if(!f(t))return"F";if(!n)return"E";s(t)}return t[e].i},h=function(t,n){if(!o(t,e)){if(!f(t))return!0;if(!n)return!1;s(t)}return t[e].w},v=function(t){return a&&p.NEED&&f(t)&&!o(t,e)&&s(t),t},p=t.exports={KEY:e,NEED:!1,fastKey:l,getWeak:h,onFreeze:v}},function(t,n){t.exports=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}},function(t,n){var r=Math.ceil,e=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?e:r)(t)}},function(t,n){t.exports=function(t,n,r,e){if(!(t instanceof n)||void 0!==e&&e in t)throw TypeError(r+": incorrect invocation!");return t}},function(t,n){t.exports=!1},function(t,n,r){var e=r(2),i=r(173),o=r(133),u=r(145)("IE_PROTO"),c=function(){},f="prototype",a=function(){var t,n=r(132)("iframe"),e=o.length;for(n.style.display="none",r(135).appendChild(n),n.src="javascript:",t=n.contentWindow.document,t.open(),t.write("<script>document.F=Object<\/script>"),t.close(),a=t.F;e--;)delete a[f][o[e]];return a()};t.exports=Object.create||function(t,n){var r;return null!==t?(c[f]=e(t),r=new c,c[f]=null,r[u]=t):r=a(),void 0===n?r:i(r,n)}},function(t,n,r){var e=r(175),i=r(133).concat("length","prototype");n.f=Object.getOwnPropertyNames||function(t){return e(t,i)}},function(t,n,r){var e=r(175),i=r(133);t.exports=Object.keys||function(t){return e(t,i)}},function(t,n,r){var e=r(28);t.exports=function(t,n,r){for(var i in n)e(t,i,n[i],r);return t}},function(t,n,r){"use strict";var e=r(3),i=r(11),o=r(10),u=r(7)("species");t.exports=function(t){var n=e[t];o&&n&&!n[u]&&i.f(n,u,{configurable:!0,get:function(){return this}})}},function(t,n,r){var e=r(67),i=Math.max,o=Math.min;t.exports=function(t,n){return t=e(t),t<0?i(t+n,0):o(t,n)}},function(t,n){var r=0,e=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++r+e).toString(36))}},function(t,n,r){var e=r(33);t.exports=function(t){return Object(e(t))}},function(t,n,r){var e=r(7)("unscopables"),i=Array.prototype;void 0==i[e]&&r(27)(i,e,{}),t.exports=function(t){i[e][t]=!0}},function(t,n,r){var e=r(53),i=r(169),o=r(137),u=r(2),c=r(16),f=r(154),a={},s={},n=t.exports=function(t,n,r,l,h){var v,p,d,y,g=h?function(){return t}:f(t),b=e(r,l,n?2:1),m=0;if("function"!=typeof g)throw TypeError(t+" is not iterable!");if(o(g)){for(v=c(t.length);v>m;m++)if((y=n?b(u(p=t[m])[0],p[1]):b(t[m]))===a||y===s)return y}else for(d=g.call(t);!(p=d.next()).done;)if((y=i(d,b,p.value,n))===a||y===s)return y};n.BREAK=a,n.RETURN=s},function(t,n){t.exports={}},function(t,n,r){var e=r(11).f,i=r(24),o=r(7)("toStringTag");t.exports=function(t,n,r){t&&!i(t=r?t:t.prototype,o)&&e(t,o,{configurable:!0,value:n})}},function(t,n,r){var e=r(1),i=r(46),o=r(4),u=r(150),c="["+u+"]",f="​",a=RegExp("^"+c+c+"*"),s=RegExp(c+c+"*$"),l=function(t,n,r){var i={},c=o(function(){return!!u[t]()||f[t]()!=f}),a=i[t]=c?n(h):u[t];r&&(i[r]=a),e(e.P+e.F*c,"String",i)},h=l.trim=function(t,n){return t=String(i(t)),1&n&&(t=t.replace(a,"")),2&n&&(t=t.replace(s,"")),t};t.exports=l},function(t,n,r){t.exports={default:r(86),__esModule:!0}},function(t,n,r){t.exports={default:r(87),__esModule:!0}},function(t,n,r){"use strict";function e(t){return t&&t.__esModule?t:{default:t}}n.__esModule=!0;var i=r(84),o=e(i),u=r(83),c=e(u),f="function"==typeof c.default&&"symbol"==typeof o.default?function(t){return typeof t}:function(t){return t&&"function"==typeof c.default&&t.constructor===c.default&&t!==c.default.prototype?"symbol":typeof t};n.default="function"==typeof c.default&&"symbol"===f(o.default)?function(t){return void 0===t?"undefined":f(t)}:function(t){return t&&"function"==typeof c.default&&t.constructor===c.default&&t!==c.default.prototype?"symbol":void 0===t?"undefined":f(t)}},function(t,n,r){r(110),r(108),r(111),r(112),t.exports=r(25).Symbol},function(t,n,r){r(109),r(113),t.exports=r(44).f("iterator")},function(t,n){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,n){t.exports=function(){}},function(t,n,r){var e=r(9),i=r(106),o=r(105);t.exports=function(t){return function(n,r,u){var c,f=e(n),a=i(f.length),s=o(u,a);if(t&&r!=r){for(;a>s;)if((c=f[s++])!=c)return!0}else for(;a>s;s++)if((t||s in f)&&f[s]===r)return t||s||0;return!t&&-1}}},function(t,n,r){var e=r(88);t.exports=function(t,n,r){if(e(t),void 0===n)return t;switch(r){case 1:return function(r){return t.call(n,r)};case 2:return function(r,e){return t.call(n,r,e)};case 3:return function(r,e,i){return t.call(n,r,e,i)}}return function(){return t.apply(n,arguments)}}},function(t,n,r){var e=r(19),i=r(62),o=r(37);t.exports=function(t){var n=e(t),r=i.f;if(r)for(var u,c=r(t),f=o.f,a=0;c.length>a;)f.call(t,u=c[a++])&&n.push(u);return n}},function(t,n,r){t.exports=r(5).document&&document.documentElement},function(t,n,r){var e=r(56);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==e(t)?t.split(""):Object(t)}},function(t,n,r){var e=r(56);t.exports=Array.isArray||function(t){return"Array"==e(t)}},function(t,n,r){"use strict";var e=r(60),i=r(22),o=r(38),u={};r(13)(u,r(15)("iterator"),function(){return this}),t.exports=function(t,n,r){t.prototype=e(u,{next:i(1,r)}),o(t,n+" Iterator")}},function(t,n){t.exports=function(t,n){return{value:n,done:!!t}}},function(t,n,r){var e=r(19),i=r(9);t.exports=function(t,n){for(var r,o=i(t),u=e(o),c=u.length,f=0;c>f;)if(o[r=u[f++]]===n)return r}},function(t,n,r){var e=r(23)("meta"),i=r(21),o=r(8),u=r(14).f,c=0,f=Object.isExtensible||function(){return!0},a=!r(18)(function(){return f(Object.preventExtensions({}))}),s=function(t){u(t,e,{value:{i:"O"+ ++c,w:{}}})},l=function(t,n){if(!i(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!o(t,e)){if(!f(t))return"F";if(!n)return"E";s(t)}return t[e].i},h=function(t,n){if(!o(t,e)){if(!f(t))return!0;if(!n)return!1;s(t)}return t[e].w},v=function(t){return a&&p.NEED&&f(t)&&!o(t,e)&&s(t),t},p=t.exports={KEY:e,NEED:!1,fastKey:l,getWeak:h,onFreeze:v}},function(t,n,r){var e=r(14),i=r(20),o=r(19);t.exports=r(12)?Object.defineProperties:function(t,n){i(t);for(var r,u=o(n),c=u.length,f=0;c>f;)e.f(t,r=u[f++],n[r]);return t}},function(t,n,r){var e=r(37),i=r(22),o=r(9),u=r(42),c=r(8),f=r(58),a=Object.getOwnPropertyDescriptor;n.f=r(12)?a:function(t,n){if(t=o(t),n=u(n,!0),f)try{return a(t,n)}catch(t){}if(c(t,n))return i(!e.f.call(t,n),t[n])}},function(t,n,r){var e=r(9),i=r(61).f,o={}.toString,u="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],c=function(t){try{return i(t)}catch(t){return u.slice()}};t.exports.f=function(t){return u&&"[object Window]"==o.call(t)?c(t):i(e(t))}},function(t,n,r){var e=r(8),i=r(77),o=r(39)("IE_PROTO"),u=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=i(t),e(t,o)?t[o]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?u:null}},function(t,n,r){var e=r(41),i=r(33);t.exports=function(t){return function(n,r){var o,u,c=String(i(n)),f=e(r),a=c.length;return f<0||f>=a?t?"":void 0:(o=c.charCodeAt(f),o<55296||o>56319||f+1===a||(u=c.charCodeAt(f+1))<56320||u>57343?t?c.charAt(f):o:t?c.slice(f,f+2):u-56320+(o-55296<<10)+65536)}}},function(t,n,r){var e=r(41),i=Math.max,o=Math.min;t.exports=function(t,n){return t=e(t),t<0?i(t+n,0):o(t,n)}},function(t,n,r){var e=r(41),i=Math.min;t.exports=function(t){return t>0?i(e(t),9007199254740991):0}},function(t,n,r){"use strict";var e=r(89),i=r(97),o=r(35),u=r(9);t.exports=r(59)(Array,"Array",function(t,n){this._t=u(t),this._i=0,this._k=n},function(){var t=this._t,n=this._k,r=this._i++;return!t||r>=t.length?(this._t=void 0,i(1)):"keys"==n?i(0,r):"values"==n?i(0,t[r]):i(0,[r,t[r]])},"values"),o.Arguments=o.Array,e("keys"),e("values"),e("entries")},function(t,n){},function(t,n,r){"use strict";var e=r(104)(!0);r(59)(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,n=this._t,r=this._i;return r>=n.length?{value:void 0,done:!0}:(t=e(n,r),this._i+=t.length,{value:t,done:!1})})},function(t,n,r){"use strict";var e=r(5),i=r(8),o=r(12),u=r(51),c=r(64),f=r(99).KEY,a=r(18),s=r(40),l=r(38),h=r(23),v=r(15),p=r(44),d=r(43),y=r(98),g=r(92),b=r(95),m=r(20),x=r(9),w=r(42),S=r(22),_=r(60),O=r(102),E=r(101),P=r(14),j=r(19),F=E.f,M=P.f,A=O.f,N=e.Symbol,T=e.JSON,I=T&&T.stringify,k="prototype",L=v("_hidden"),R=v("toPrimitive"),C={}.propertyIsEnumerable,D=s("symbol-registry"),U=s("symbols"),W=s("op-symbols"),G=Object[k],B="function"==typeof N,V=e.QObject,z=!V||!V[k]||!V[k].findChild,q=o&&a(function(){return 7!=_(M({},"a",{get:function(){return M(this,"a",{value:7}).a}})).a})?function(t,n,r){var e=F(G,n);e&&delete G[n],M(t,n,r),e&&t!==G&&M(G,n,e)}:M,K=function(t){var n=U[t]=_(N[k]);return n._k=t,n},J=B&&"symbol"==typeof N.iterator?function(t){return"symbol"==typeof t}:function(t){return t instanceof N},Y=function(t,n,r){return t===G&&Y(W,n,r),m(t),n=w(n,!0),m(r),i(U,n)?(r.enumerable?(i(t,L)&&t[L][n]&&(t[L][n]=!1),r=_(r,{enumerable:S(0,!1)})):(i(t,L)||M(t,L,S(1,{})),t[L][n]=!0),q(t,n,r)):M(t,n,r)},H=function(t,n){m(t);for(var r,e=g(n=x(n)),i=0,o=e.length;o>i;)Y(t,r=e[i++],n[r]);return t},$=function(t,n){return void 0===n?_(t):H(_(t),n)},X=function(t){var n=C.call(this,t=w(t,!0));return!(this===G&&i(U,t)&&!i(W,t))&&(!(n||!i(this,t)||!i(U,t)||i(this,L)&&this[L][t])||n)},Q=function(t,n){if(t=x(t),n=w(n,!0),t!==G||!i(U,n)||i(W,n)){var r=F(t,n);return!r||!i(U,n)||i(t,L)&&t[L][n]||(r.enumerable=!0),r}},Z=function(t){for(var n,r=A(x(t)),e=[],o=0;r.length>o;)i(U,n=r[o++])||n==L||n==f||e.push(n);return e},tt=function(t){for(var n,r=t===G,e=A(r?W:x(t)),o=[],u=0;e.length>u;)!i(U,n=e[u++])||r&&!i(G,n)||o.push(U[n]);return o};B||(N=function(){if(this instanceof N)throw TypeError("Symbol is not a constructor!");var t=h(arguments.length>0?arguments[0]:void 0),n=function(r){this===G&&n.call(W,r),i(this,L)&&i(this[L],t)&&(this[L][t]=!1),q(this,t,S(1,r))};return o&&z&&q(G,t,{configurable:!0,set:n}),K(t)},c(N[k],"toString",function(){return this._k}),E.f=Q,P.f=Y,r(61).f=O.f=Z,r(37).f=X,r(62).f=tt,o&&!r(36)&&c(G,"propertyIsEnumerable",X,!0),p.f=function(t){return K(v(t))}),u(u.G+u.W+u.F*!B,{Symbol:N});for(var nt="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),rt=0;nt.length>rt;)v(nt[rt++]);for(var nt=j(v.store),rt=0;nt.length>rt;)d(nt[rt++]);u(u.S+u.F*!B,"Symbol",{for:function(t){return i(D,t+="")?D[t]:D[t]=N(t)},keyFor:function(t){if(J(t))return y(D,t);throw TypeError(t+" is not a symbol!")},useSetter:function(){z=!0},useSimple:function(){z=!1}}),u(u.S+u.F*!B,"Object",{create:$,defineProperty:Y,defineProperties:H,getOwnPropertyDescriptor:Q,getOwnPropertyNames:Z,getOwnPropertySymbols:tt}),T&&u(u.S+u.F*(!B||a(function(){var t=N();return"[null]"!=I([t])||"{}"!=I({a:t})||"{}"!=I(Object(t))})),"JSON",{stringify:function(t){if(void 0!==t&&!J(t)){for(var n,r,e=[t],i=1;arguments.length>i;)e.push(arguments[i++]);return n=e[1],"function"==typeof n&&(r=n),!r&&b(n)||(n=function(t,n){if(r&&(n=r.call(this,t,n)),!J(n))return n}),e[1]=n,I.apply(T,e)}}}),N[k][R]||r(13)(N[k],R,N[k].valueOf),l(N,"Symbol"),l(Math,"Math",!0),l(e.JSON,"JSON",!0)},function(t,n,r){r(43)("asyncIterator")},function(t,n,r){r(43)("observable")},function(t,n,r){r(107);for(var e=r(5),i=r(13),o=r(35),u=r(15)("toStringTag"),c=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],f=0;f<5;f++){var a=c[f],s=e[a],l=s&&s.prototype;l&&!l[u]&&i(l,u,a),o[a]=o.Array}},function(t,n,r){var e=r(45),i=r(7)("toStringTag"),o="Arguments"==e(function(){return arguments}()),u=function(t,n){try{return t[n]}catch(t){}};t.exports=function(t){var n,r,c;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=u(n=Object(t),i))?r:o?e(n):"Object"==(c=e(n))&&"function"==typeof n.callee?"Arguments":c}},function(t,n,r){var e=r(45);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==e(t)?t.split(""):Object(t)}},function(t,n){n.f={}.propertyIsEnumerable},function(t,n,r){var e=r(30),i=r(16),o=r(75);t.exports=function(t){return function(n,r,u){var c,f=e(n),a=i(f.length),s=o(u,a);if(t&&r!=r){for(;a>s;)if((c=f[s++])!=c)return!0}else for(;a>s;s++)if((t||s in f)&&f[s]===r)return t||s||0;return!t&&-1}}},function(t,n,r){"use strict";var e=r(3),i=r(1),o=r(28),u=r(73),c=r(65),f=r(79),a=r(68),s=r(6),l=r(4),h=r(123),v=r(81),p=r(136);t.exports=function(t,n,r,d,y,g){var b=e[t],m=b,x=y?"set":"add",w=m&&m.prototype,S={},_=function(t){var n=w[t];o(w,t,"delete"==t?function(t){return!(g&&!s(t))&&n.call(this,0===t?0:t)}:"has"==t?function(t){return!(g&&!s(t))&&n.call(this,0===t?0:t)}:"get"==t?function(t){return g&&!s(t)?void 0:n.call(this,0===t?0:t)}:"add"==t?function(t){return n.call(this,0===t?0:t),this}:function(t,r){return n.call(this,0===t?0:t,r),this})};if("function"==typeof m&&(g||w.forEach&&!l(function(){(new m).entries().next()}))){var O=new m,E=O[x](g?{}:-0,1)!=O,P=l(function(){O.has(1)}),j=h(function(t){new m(t)}),F=!g&&l(function(){for(var t=new m,n=5;n--;)t[x](n,n);return!t.has(-0)});j||(m=n(function(n,r){a(n,m,t);var e=p(new b,n,m);return void 0!=r&&f(r,y,e[x],e),e}),m.prototype=w,w.constructor=m),(P||F)&&(_("delete"),_("has"),y&&_("get")),(F||E)&&_(x),g&&w.clear&&delete w.clear}else m=d.getConstructor(n,t,y,x),u(m.prototype,r),c.NEED=!0;return v(m,t),S[t]=m,i(i.G+i.W+i.F*(m!=b),S),g||d.setStrong(m,t,y),m}},function(t,n,r){"use strict";var e=r(27),i=r(28),o=r(4),u=r(46),c=r(7);t.exports=function(t,n,r){var f=c(t),a=r(u,f,""[t]),s=a[0],l=a[1];o(function(){var n={};return n[f]=function(){return 7},7!=""[t](n)})&&(i(String.prototype,t,s),e(RegExp.prototype,f,2==n?function(t,n){return l.call(t,this,n)}:function(t){return l.call(t,this)}))}
},function(t,n,r){"use strict";var e=r(2);t.exports=function(){var t=e(this),n="";return t.global&&(n+="g"),t.ignoreCase&&(n+="i"),t.multiline&&(n+="m"),t.unicode&&(n+="u"),t.sticky&&(n+="y"),n}},function(t,n){t.exports=function(t,n,r){var e=void 0===r;switch(n.length){case 0:return e?t():t.call(r);case 1:return e?t(n[0]):t.call(r,n[0]);case 2:return e?t(n[0],n[1]):t.call(r,n[0],n[1]);case 3:return e?t(n[0],n[1],n[2]):t.call(r,n[0],n[1],n[2]);case 4:return e?t(n[0],n[1],n[2],n[3]):t.call(r,n[0],n[1],n[2],n[3])}return t.apply(r,n)}},function(t,n,r){var e=r(6),i=r(45),o=r(7)("match");t.exports=function(t){var n;return e(t)&&(void 0!==(n=t[o])?!!n:"RegExp"==i(t))}},function(t,n,r){var e=r(7)("iterator"),i=!1;try{var o=[7][e]();o.return=function(){i=!0},Array.from(o,function(){throw 2})}catch(t){}t.exports=function(t,n){if(!n&&!i)return!1;var r=!1;try{var o=[7],u=o[e]();u.next=function(){return{done:r=!0}},o[e]=function(){return u},t(o)}catch(t){}return r}},function(t,n,r){t.exports=r(69)||!r(4)(function(){var t=Math.random();__defineSetter__.call(null,t,function(){}),delete r(3)[t]})},function(t,n){n.f=Object.getOwnPropertySymbols},function(t,n,r){var e=r(3),i="__core-js_shared__",o=e[i]||(e[i]={});t.exports=function(t){return o[t]||(o[t]={})}},function(t,n,r){for(var e,i=r(3),o=r(27),u=r(76),c=u("typed_array"),f=u("view"),a=!(!i.ArrayBuffer||!i.DataView),s=a,l=0,h="Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array".split(",");l<9;)(e=i[h[l++]])?(o(e.prototype,c,!0),o(e.prototype,f,!0)):s=!1;t.exports={ABV:a,CONSTR:s,TYPED:c,VIEW:f}},function(t,n){"use strict";var r={versions:function(){var t=window.navigator.userAgent;return{trident:t.indexOf("Trident")>-1,presto:t.indexOf("Presto")>-1,webKit:t.indexOf("AppleWebKit")>-1,gecko:t.indexOf("Gecko")>-1&&-1==t.indexOf("KHTML"),mobile:!!t.match(/AppleWebKit.*Mobile.*/),ios:!!t.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),android:t.indexOf("Android")>-1||t.indexOf("Linux")>-1,iPhone:t.indexOf("iPhone")>-1||t.indexOf("Mac")>-1,iPad:t.indexOf("iPad")>-1,webApp:-1==t.indexOf("Safari"),weixin:-1==t.indexOf("MicroMessenger")}}()};t.exports=r},function(t,n,r){"use strict";var e=r(85),i=function(t){return t&&t.__esModule?t:{default:t}}(e),o=function(){function t(t,n,e){return n||e?String.fromCharCode(n||e):r[t]||t}function n(t){return e[t]}var r={"&quot;":'"',"&lt;":"<","&gt;":">","&amp;":"&","&nbsp;":" "},e={};for(var u in r)e[r[u]]=u;return r["&apos;"]="'",e["'"]="&#39;",{encode:function(t){return t?(""+t).replace(/['<> "&]/g,n).replace(/\r?\n/g,"<br/>").replace(/\s/g,"&nbsp;"):""},decode:function(n){return n?(""+n).replace(/<br\s*\/?>/gi,"\n").replace(/&quot;|&lt;|&gt;|&amp;|&nbsp;|&apos;|&#(\d+);|&#(\d+)/g,t).replace(/\u00a0/g," "):""},encodeBase16:function(t){if(!t)return t;t+="";for(var n=[],r=0,e=t.length;e>r;r++)n.push(t.charCodeAt(r).toString(16).toUpperCase());return n.join("")},encodeBase16forJSON:function(t){if(!t)return t;t=t.replace(/[\u4E00-\u9FBF]/gi,function(t){return escape(t).replace("%u","\\u")});for(var n=[],r=0,e=t.length;e>r;r++)n.push(t.charCodeAt(r).toString(16).toUpperCase());return n.join("")},decodeBase16:function(t){if(!t)return t;t+="";for(var n=[],r=0,e=t.length;e>r;r+=2)n.push(String.fromCharCode("0x"+t.slice(r,r+2)));return n.join("")},encodeObject:function(t){if(t instanceof Array)for(var n=0,r=t.length;r>n;n++)t[n]=o.encodeObject(t[n]);else if("object"==(void 0===t?"undefined":(0,i.default)(t)))for(var e in t)t[e]=o.encodeObject(t[e]);else if("string"==typeof t)return o.encode(t);return t},loadScript:function(t){var n=document.createElement("script");document.getElementsByTagName("body")[0].appendChild(n),n.setAttribute("src",t)},addLoadEvent:function(t){var n=window.onload;"function"!=typeof window.onload?window.onload=t:window.onload=function(){n(),t()}}}}();t.exports=o},function(t,n,r){"use strict";var e=r(17),i=r(75),o=r(16);t.exports=function(t){for(var n=e(this),r=o(n.length),u=arguments.length,c=i(u>1?arguments[1]:void 0,r),f=u>2?arguments[2]:void 0,a=void 0===f?r:i(f,r);a>c;)n[c++]=t;return n}},function(t,n,r){"use strict";var e=r(11),i=r(66);t.exports=function(t,n,r){n in t?e.f(t,n,i(0,r)):t[n]=r}},function(t,n,r){var e=r(6),i=r(3).document,o=e(i)&&e(i.createElement);t.exports=function(t){return o?i.createElement(t):{}}},function(t,n){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,n,r){var e=r(7)("match");t.exports=function(t){var n=/./;try{"/./"[t](n)}catch(r){try{return n[e]=!1,!"/./"[t](n)}catch(t){}}return!0}},function(t,n,r){t.exports=r(3).document&&document.documentElement},function(t,n,r){var e=r(6),i=r(144).set;t.exports=function(t,n,r){var o,u=n.constructor;return u!==r&&"function"==typeof u&&(o=u.prototype)!==r.prototype&&e(o)&&i&&i(t,o),t}},function(t,n,r){var e=r(80),i=r(7)("iterator"),o=Array.prototype;t.exports=function(t){return void 0!==t&&(e.Array===t||o[i]===t)}},function(t,n,r){var e=r(45);t.exports=Array.isArray||function(t){return"Array"==e(t)}},function(t,n,r){"use strict";var e=r(70),i=r(66),o=r(81),u={};r(27)(u,r(7)("iterator"),function(){return this}),t.exports=function(t,n,r){t.prototype=e(u,{next:i(1,r)}),o(t,n+" Iterator")}},function(t,n,r){"use strict";var e=r(69),i=r(1),o=r(28),u=r(27),c=r(24),f=r(80),a=r(139),s=r(81),l=r(32),h=r(7)("iterator"),v=!([].keys&&"next"in[].keys()),p="keys",d="values",y=function(){return this};t.exports=function(t,n,r,g,b,m,x){a(r,n,g);var w,S,_,O=function(t){if(!v&&t in F)return F[t];switch(t){case p:case d:return function(){return new r(this,t)}}return function(){return new r(this,t)}},E=n+" Iterator",P=b==d,j=!1,F=t.prototype,M=F[h]||F["@@iterator"]||b&&F[b],A=M||O(b),N=b?P?O("entries"):A:void 0,T="Array"==n?F.entries||M:M;if(T&&(_=l(T.call(new t)))!==Object.prototype&&(s(_,E,!0),e||c(_,h)||u(_,h,y)),P&&M&&M.name!==d&&(j=!0,A=function(){return M.call(this)}),e&&!x||!v&&!j&&F[h]||u(F,h,A),f[n]=A,f[E]=y,b)if(w={values:P?A:O(d),keys:m?A:O(p),entries:N},x)for(S in w)S in F||o(F,S,w[S]);else i(i.P+i.F*(v||j),n,w);return w}},function(t,n){var r=Math.expm1;t.exports=!r||r(10)>22025.465794806718||r(10)<22025.465794806718||-2e-17!=r(-2e-17)?function(t){return 0==(t=+t)?t:t>-1e-6&&t<1e-6?t+t*t/2:Math.exp(t)-1}:r},function(t,n){t.exports=Math.sign||function(t){return 0==(t=+t)||t!=t?t:t<0?-1:1}},function(t,n,r){var e=r(3),i=r(151).set,o=e.MutationObserver||e.WebKitMutationObserver,u=e.process,c=e.Promise,f="process"==r(45)(u);t.exports=function(){var t,n,r,a=function(){var e,i;for(f&&(e=u.domain)&&e.exit();t;){i=t.fn,t=t.next;try{i()}catch(e){throw t?r():n=void 0,e}}n=void 0,e&&e.enter()};if(f)r=function(){u.nextTick(a)};else if(o){var s=!0,l=document.createTextNode("");new o(a).observe(l,{characterData:!0}),r=function(){l.data=s=!s}}else if(c&&c.resolve){var h=c.resolve();r=function(){h.then(a)}}else r=function(){i.call(e,a)};return function(e){var i={fn:e,next:void 0};n&&(n.next=i),t||(t=i,r()),n=i}}},function(t,n,r){var e=r(6),i=r(2),o=function(t,n){if(i(t),!e(n)&&null!==n)throw TypeError(n+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(t,n,e){try{e=r(53)(Function.call,r(31).f(Object.prototype,"__proto__").set,2),e(t,[]),n=!(t instanceof Array)}catch(t){n=!0}return function(t,r){return o(t,r),n?t.__proto__=r:e(t,r),t}}({},!1):void 0),check:o}},function(t,n,r){var e=r(126)("keys"),i=r(76);t.exports=function(t){return e[t]||(e[t]=i(t))}},function(t,n,r){var e=r(2),i=r(26),o=r(7)("species");t.exports=function(t,n){var r,u=e(t).constructor;return void 0===u||void 0==(r=e(u)[o])?n:i(r)}},function(t,n,r){var e=r(67),i=r(46);t.exports=function(t){return function(n,r){var o,u,c=String(i(n)),f=e(r),a=c.length;return f<0||f>=a?t?"":void 0:(o=c.charCodeAt(f),o<55296||o>56319||f+1===a||(u=c.charCodeAt(f+1))<56320||u>57343?t?c.charAt(f):o:t?c.slice(f,f+2):u-56320+(o-55296<<10)+65536)}}},function(t,n,r){var e=r(122),i=r(46);t.exports=function(t,n,r){if(e(n))throw TypeError("String#"+r+" doesn't accept regex!");return String(i(t))}},function(t,n,r){"use strict";var e=r(67),i=r(46);t.exports=function(t){var n=String(i(this)),r="",o=e(t);if(o<0||o==1/0)throw RangeError("Count can't be negative");for(;o>0;(o>>>=1)&&(n+=n))1&o&&(r+=n);return r}},function(t,n){t.exports="\t\n\v\f\r   ᠎             　\u2028\u2029\ufeff"},function(t,n,r){var e,i,o,u=r(53),c=r(121),f=r(135),a=r(132),s=r(3),l=s.process,h=s.setImmediate,v=s.clearImmediate,p=s.MessageChannel,d=0,y={},g="onreadystatechange",b=function(){var t=+this;if(y.hasOwnProperty(t)){var n=y[t];delete y[t],n()}},m=function(t){b.call(t.data)};h&&v||(h=function(t){for(var n=[],r=1;arguments.length>r;)n.push(arguments[r++]);return y[++d]=function(){c("function"==typeof t?t:Function(t),n)},e(d),d},v=function(t){delete y[t]},"process"==r(45)(l)?e=function(t){l.nextTick(u(b,t,1))}:p?(i=new p,o=i.port2,i.port1.onmessage=m,e=u(o.postMessage,o,1)):s.addEventListener&&"function"==typeof postMessage&&!s.importScripts?(e=function(t){s.postMessage(t+"","*")},s.addEventListener("message",m,!1)):e=g in a("script")?function(t){f.appendChild(a("script"))[g]=function(){f.removeChild(this),b.call(t)}}:function(t){setTimeout(u(b,t,1),0)}),t.exports={set:h,clear:v}},function(t,n,r){"use strict";var e=r(3),i=r(10),o=r(69),u=r(127),c=r(27),f=r(73),a=r(4),s=r(68),l=r(67),h=r(16),v=r(71).f,p=r(11).f,d=r(130),y=r(81),g="ArrayBuffer",b="DataView",m="prototype",x="Wrong length!",w="Wrong index!",S=e[g],_=e[b],O=e.Math,E=e.RangeError,P=e.Infinity,j=S,F=O.abs,M=O.pow,A=O.floor,N=O.log,T=O.LN2,I="buffer",k="byteLength",L="byteOffset",R=i?"_b":I,C=i?"_l":k,D=i?"_o":L,U=function(t,n,r){var e,i,o,u=Array(r),c=8*r-n-1,f=(1<<c)-1,a=f>>1,s=23===n?M(2,-24)-M(2,-77):0,l=0,h=t<0||0===t&&1/t<0?1:0;for(t=F(t),t!=t||t===P?(i=t!=t?1:0,e=f):(e=A(N(t)/T),t*(o=M(2,-e))<1&&(e--,o*=2),t+=e+a>=1?s/o:s*M(2,1-a),t*o>=2&&(e++,o/=2),e+a>=f?(i=0,e=f):e+a>=1?(i=(t*o-1)*M(2,n),e+=a):(i=t*M(2,a-1)*M(2,n),e=0));n>=8;u[l++]=255&i,i/=256,n-=8);for(e=e<<n|i,c+=n;c>0;u[l++]=255&e,e/=256,c-=8);return u[--l]|=128*h,u},W=function(t,n,r){var e,i=8*r-n-1,o=(1<<i)-1,u=o>>1,c=i-7,f=r-1,a=t[f--],s=127&a;for(a>>=7;c>0;s=256*s+t[f],f--,c-=8);for(e=s&(1<<-c)-1,s>>=-c,c+=n;c>0;e=256*e+t[f],f--,c-=8);if(0===s)s=1-u;else{if(s===o)return e?NaN:a?-P:P;e+=M(2,n),s-=u}return(a?-1:1)*e*M(2,s-n)},G=function(t){return t[3]<<24|t[2]<<16|t[1]<<8|t[0]},B=function(t){return[255&t]},V=function(t){return[255&t,t>>8&255]},z=function(t){return[255&t,t>>8&255,t>>16&255,t>>24&255]},q=function(t){return U(t,52,8)},K=function(t){return U(t,23,4)},J=function(t,n,r){p(t[m],n,{get:function(){return this[r]}})},Y=function(t,n,r,e){var i=+r,o=l(i);if(i!=o||o<0||o+n>t[C])throw E(w);var u=t[R]._b,c=o+t[D],f=u.slice(c,c+n);return e?f:f.reverse()},H=function(t,n,r,e,i,o){var u=+r,c=l(u);if(u!=c||c<0||c+n>t[C])throw E(w);for(var f=t[R]._b,a=c+t[D],s=e(+i),h=0;h<n;h++)f[a+h]=s[o?h:n-h-1]},$=function(t,n){s(t,S,g);var r=+n,e=h(r);if(r!=e)throw E(x);return e};if(u.ABV){if(!a(function(){new S})||!a(function(){new S(.5)})){S=function(t){return new j($(this,t))};for(var X,Q=S[m]=j[m],Z=v(j),tt=0;Z.length>tt;)(X=Z[tt++])in S||c(S,X,j[X]);o||(Q.constructor=S)}var nt=new _(new S(2)),rt=_[m].setInt8;nt.setInt8(0,2147483648),nt.setInt8(1,2147483649),!nt.getInt8(0)&&nt.getInt8(1)||f(_[m],{setInt8:function(t,n){rt.call(this,t,n<<24>>24)},setUint8:function(t,n){rt.call(this,t,n<<24>>24)}},!0)}else S=function(t){var n=$(this,t);this._b=d.call(Array(n),0),this[C]=n},_=function(t,n,r){s(this,_,b),s(t,S,b);var e=t[C],i=l(n);if(i<0||i>e)throw E("Wrong offset!");if(r=void 0===r?e-i:h(r),i+r>e)throw E(x);this[R]=t,this[D]=i,this[C]=r},i&&(J(S,k,"_l"),J(_,I,"_b"),J(_,k,"_l"),J(_,L,"_o")),f(_[m],{getInt8:function(t){return Y(this,1,t)[0]<<24>>24},getUint8:function(t){return Y(this,1,t)[0]},getInt16:function(t){var n=Y(this,2,t,arguments[1]);return(n[1]<<8|n[0])<<16>>16},getUint16:function(t){var n=Y(this,2,t,arguments[1]);return n[1]<<8|n[0]},getInt32:function(t){return G(Y(this,4,t,arguments[1]))},getUint32:function(t){return G(Y(this,4,t,arguments[1]))>>>0},getFloat32:function(t){return W(Y(this,4,t,arguments[1]),23,4)},getFloat64:function(t){return W(Y(this,8,t,arguments[1]),52,8)},setInt8:function(t,n){H(this,1,t,B,n)},setUint8:function(t,n){H(this,1,t,B,n)},setInt16:function(t,n){H(this,2,t,V,n,arguments[2])},setUint16:function(t,n){H(this,2,t,V,n,arguments[2])},setInt32:function(t,n){H(this,4,t,z,n,arguments[2])},setUint32:function(t,n){H(this,4,t,z,n,arguments[2])},setFloat32:function(t,n){H(this,4,t,K,n,arguments[2])},setFloat64:function(t,n){H(this,8,t,q,n,arguments[2])}});y(S,g),y(_,b),c(_[m],u.VIEW,!0),n[g]=S,n[b]=_},function(t,n,r){var e=r(3),i=r(52),o=r(69),u=r(182),c=r(11).f;t.exports=function(t){var n=i.Symbol||(i.Symbol=o?{}:e.Symbol||{});"_"==t.charAt(0)||t in n||c(n,t,{value:u.f(t)})}},function(t,n,r){var e=r(114),i=r(7)("iterator"),o=r(80);t.exports=r(52).getIteratorMethod=function(t){if(void 0!=t)return t[i]||t["@@iterator"]||o[e(t)]}},function(t,n,r){"use strict";var e=r(78),i=r(170),o=r(80),u=r(30);t.exports=r(140)(Array,"Array",function(t,n){this._t=u(t),this._i=0,this._k=n},function(){var t=this._t,n=this._k,r=this._i++;return!t||r>=t.length?(this._t=void 0,i(1)):"keys"==n?i(0,r):"values"==n?i(0,t[r]):i(0,[r,t[r]])},"values"),o.Arguments=o.Array,e("keys"),e("values"),e("entries")},function(t,n){function r(t,n){t.classList?t.classList.add(n):t.className+=" "+n}t.exports=r},function(t,n){function r(t,n){if(t.classList)t.classList.remove(n);else{var r=new RegExp("(^|\\b)"+n.split(" ").join("|")+"(\\b|$)","gi");t.className=t.className.replace(r," ")}}t.exports=r},function(t,n){function r(){throw new Error("setTimeout has not been defined")}function e(){throw new Error("clearTimeout has not been defined")}function i(t){if(s===setTimeout)return setTimeout(t,0);if((s===r||!s)&&setTimeout)return s=setTimeout,setTimeout(t,0);try{return s(t,0)}catch(n){try{return s.call(null,t,0)}catch(n){return s.call(this,t,0)}}}function o(t){if(l===clearTimeout)return clearTimeout(t);if((l===e||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(t);try{return l(t)}catch(n){try{return l.call(null,t)}catch(n){return l.call(this,t)}}}function u(){d&&v&&(d=!1,v.length?p=v.concat(p):y=-1,p.length&&c())}function c(){if(!d){var t=i(u);d=!0;for(var n=p.length;n;){for(v=p,p=[];++y<n;)v&&v[y].run();y=-1,n=p.length}v=null,d=!1,o(t)}}function f(t,n){this.fun=t,this.array=n}function a(){}var s,l,h=t.exports={};!function(){try{s="function"==typeof setTimeout?setTimeout:r}catch(t){s=r}try{l="function"==typeof clearTimeout?clearTimeout:e}catch(t){l=e}}();var v,p=[],d=!1,y=-1;h.nextTick=function(t){var n=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)n[r-1]=arguments[r];p.push(new f(t,n)),1!==p.length||d||i(c)},f.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=a,h.addListener=a,h.once=a,h.off=a,h.removeListener=a,h.removeAllListeners=a,h.emit=a,h.prependListener=a,h.prependOnceListener=a,h.listeners=function(t){return[]},h.binding=function(t){throw new Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(t){throw new Error("process.chdir is not supported")},h.umask=function(){return 0}},function(t,n,r){var e=r(45);t.exports=function(t,n){if("number"!=typeof t&&"Number"!=e(t))throw TypeError(n);return+t}},function(t,n,r){"use strict";var e=r(17),i=r(75),o=r(16);t.exports=[].copyWithin||function(t,n){var r=e(this),u=o(r.length),c=i(t,u),f=i(n,u),a=arguments.length>2?arguments[2]:void 0,s=Math.min((void 0===a?u:i(a,u))-f,u-c),l=1;for(f<c&&c<f+s&&(l=-1,f+=s-1,c+=s-1);s-- >0;)f in r?r[c]=r[f]:delete r[c],c+=l,f+=l;return r}},function(t,n,r){var e=r(79);t.exports=function(t,n){var r=[];return e(t,!1,r.push,r,n),r}},function(t,n,r){var e=r(26),i=r(17),o=r(115),u=r(16);t.exports=function(t,n,r,c,f){e(n);var a=i(t),s=o(a),l=u(a.length),h=f?l-1:0,v=f?-1:1;if(r<2)for(;;){if(h in s){c=s[h],h+=v;break}if(h+=v,f?h<0:l<=h)throw TypeError("Reduce of empty array with no initial value")}for(;f?h>=0:l>h;h+=v)h in s&&(c=n(c,s[h],h,a));return c}},function(t,n,r){"use strict";var e=r(26),i=r(6),o=r(121),u=[].slice,c={},f=function(t,n,r){if(!(n in c)){for(var e=[],i=0;i<n;i++)e[i]="a["+i+"]";c[n]=Function("F,a","return new F("+e.join(",")+")")}return c[n](t,r)};t.exports=Function.bind||function(t){var n=e(this),r=u.call(arguments,1),c=function(){var e=r.concat(u.call(arguments));return this instanceof c?f(n,e.length,e):o(n,e,t)};return i(n.prototype)&&(c.prototype=n.prototype),c}},function(t,n,r){"use strict";var e=r(11).f,i=r(70),o=r(73),u=r(53),c=r(68),f=r(46),a=r(79),s=r(140),l=r(170),h=r(74),v=r(10),p=r(65).fastKey,d=v?"_s":"size",y=function(t,n){var r,e=p(n);if("F"!==e)return t._i[e];for(r=t._f;r;r=r.n)if(r.k==n)return r};t.exports={getConstructor:function(t,n,r,s){var l=t(function(t,e){c(t,l,n,"_i"),t._i=i(null),t._f=void 0,t._l=void 0,t[d]=0,void 0!=e&&a(e,r,t[s],t)});return o(l.prototype,{clear:function(){for(var t=this,n=t._i,r=t._f;r;r=r.n)r.r=!0,r.p&&(r.p=r.p.n=void 0),delete n[r.i];t._f=t._l=void 0,t[d]=0},delete:function(t){var n=this,r=y(n,t);if(r){var e=r.n,i=r.p;delete n._i[r.i],r.r=!0,i&&(i.n=e),e&&(e.p=i),n._f==r&&(n._f=e),n._l==r&&(n._l=i),n[d]--}return!!r},forEach:function(t){c(this,l,"forEach");for(var n,r=u(t,arguments.length>1?arguments[1]:void 0,3);n=n?n.n:this._f;)for(r(n.v,n.k,this);n&&n.r;)n=n.p},has:function(t){return!!y(this,t)}}),v&&e(l.prototype,"size",{get:function(){return f(this[d])}}),l},def:function(t,n,r){var e,i,o=y(t,n);return o?o.v=r:(t._l=o={i:i=p(n,!0),k:n,v:r,p:e=t._l,n:void 0,r:!1},t._f||(t._f=o),e&&(e.n=o),t[d]++,"F"!==i&&(t._i[i]=o)),t},getEntry:y,setStrong:function(t,n,r){s(t,n,function(t,n){this._t=t,this._k=n,this._l=void 0},function(){for(var t=this,n=t._k,r=t._l;r&&r.r;)r=r.p;return t._t&&(t._l=r=r?r.n:t._t._f)?"keys"==n?l(0,r.k):"values"==n?l(0,r.v):l(0,[r.k,r.v]):(t._t=void 0,l(1))},r?"entries":"values",!r,!0),h(n)}}},function(t,n,r){var e=r(114),i=r(161);t.exports=function(t){return function(){if(e(this)!=t)throw TypeError(t+"#toJSON isn't generic");return i(this)}}},function(t,n,r){"use strict";var e=r(73),i=r(65).getWeak,o=r(2),u=r(6),c=r(68),f=r(79),a=r(48),s=r(24),l=a(5),h=a(6),v=0,p=function(t){return t._l||(t._l=new d)},d=function(){this.a=[]},y=function(t,n){return l(t.a,function(t){return t[0]===n})};d.prototype={get:function(t){var n=y(this,t);if(n)return n[1]},has:function(t){return!!y(this,t)},set:function(t,n){var r=y(this,t);r?r[1]=n:this.a.push([t,n])},delete:function(t){var n=h(this.a,function(n){return n[0]===t});return~n&&this.a.splice(n,1),!!~n}},t.exports={getConstructor:function(t,n,r,o){var a=t(function(t,e){c(t,a,n,"_i"),t._i=v++,t._l=void 0,void 0!=e&&f(e,r,t[o],t)});return e(a.prototype,{delete:function(t){if(!u(t))return!1;var n=i(t);return!0===n?p(this).delete(t):n&&s(n,this._i)&&delete n[this._i]},has:function(t){if(!u(t))return!1;var n=i(t);return!0===n?p(this).has(t):n&&s(n,this._i)}}),a},def:function(t,n,r){var e=i(o(n),!0);return!0===e?p(t).set(n,r):e[t._i]=r,t},ufstore:p}},function(t,n,r){t.exports=!r(10)&&!r(4)(function(){return 7!=Object.defineProperty(r(132)("div"),"a",{get:function(){return 7}}).a})},function(t,n,r){var e=r(6),i=Math.floor;t.exports=function(t){return!e(t)&&isFinite(t)&&i(t)===t}},function(t,n,r){var e=r(2);t.exports=function(t,n,r,i){try{return i?n(e(r)[0],r[1]):n(r)}catch(n){var o=t.return;throw void 0!==o&&e(o.call(t)),n}}},function(t,n){t.exports=function(t,n){return{value:n,done:!!t}}},function(t,n){t.exports=Math.log1p||function(t){return(t=+t)>-1e-8&&t<1e-8?t-t*t/2:Math.log(1+t)}},function(t,n,r){"use strict";var e=r(72),i=r(125),o=r(116),u=r(17),c=r(115),f=Object.assign;t.exports=!f||r(4)(function(){var t={},n={},r=Symbol(),e="abcdefghijklmnopqrst";return t[r]=7,e.split("").forEach(function(t){n[t]=t}),7!=f({},t)[r]||Object.keys(f({},n)).join("")!=e})?function(t,n){for(var r=u(t),f=arguments.length,a=1,s=i.f,l=o.f;f>a;)for(var h,v=c(arguments[a++]),p=s?e(v).concat(s(v)):e(v),d=p.length,y=0;d>y;)l.call(v,h=p[y++])&&(r[h]=v[h]);return r}:f},function(t,n,r){var e=r(11),i=r(2),o=r(72);t.exports=r(10)?Object.defineProperties:function(t,n){i(t);for(var r,u=o(n),c=u.length,f=0;c>f;)e.f(t,r=u[f++],n[r]);return t}},function(t,n,r){var e=r(30),i=r(71).f,o={}.toString,u="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],c=function(t){try{return i(t)}catch(t){return u.slice()}};t.exports.f=function(t){return u&&"[object Window]"==o.call(t)?c(t):i(e(t))}},function(t,n,r){var e=r(24),i=r(30),o=r(117)(!1),u=r(145)("IE_PROTO");t.exports=function(t,n){var r,c=i(t),f=0,a=[];for(r in c)r!=u&&e(c,r)&&a.push(r);for(;n.length>f;)e(c,r=n[f++])&&(~o(a,r)||a.push(r));return a}},function(t,n,r){var e=r(72),i=r(30),o=r(116).f;t.exports=function(t){return function(n){for(var r,u=i(n),c=e(u),f=c.length,a=0,s=[];f>a;)o.call(u,r=c[a++])&&s.push(t?[r,u[r]]:u[r]);return s}}},function(t,n,r){var e=r(71),i=r(125),o=r(2),u=r(3).Reflect;t.exports=u&&u.ownKeys||function(t){var n=e.f(o(t)),r=i.f;return r?n.concat(r(t)):n}},function(t,n,r){var e=r(3).parseFloat,i=r(82).trim;t.exports=1/e(r(150)+"-0")!=-1/0?function(t){var n=i(String(t),3),r=e(n);return 0===r&&"-"==n.charAt(0)?-0:r}:e},function(t,n,r){var e=r(3).parseInt,i=r(82).trim,o=r(150),u=/^[\-+]?0[xX]/;t.exports=8!==e(o+"08")||22!==e(o+"0x16")?function(t,n){var r=i(String(t),3);return e(r,n>>>0||(u.test(r)?16:10))}:e},function(t,n){t.exports=Object.is||function(t,n){return t===n?0!==t||1/t==1/n:t!=t&&n!=n}},function(t,n,r){var e=r(16),i=r(149),o=r(46);t.exports=function(t,n,r,u){var c=String(o(t)),f=c.length,a=void 0===r?" ":String(r),s=e(n);if(s<=f||""==a)return c;var l=s-f,h=i.call(a,Math.ceil(l/a.length));return h.length>l&&(h=h.slice(0,l)),u?h+c:c+h}},function(t,n,r){n.f=r(7)},function(t,n,r){"use strict";var e=r(164);t.exports=r(118)("Map",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},{get:function(t){var n=e.getEntry(this,t);return n&&n.v},set:function(t,n){return e.def(this,0===t?0:t,n)}},e,!0)},function(t,n,r){r(10)&&"g"!=/./g.flags&&r(11).f(RegExp.prototype,"flags",{configurable:!0,get:r(120)})},function(t,n,r){"use strict";var e=r(164);t.exports=r(118)("Set",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},{add:function(t){return e.def(this,t=0===t?0:t,t)}},e)},function(t,n,r){"use strict";var e,i=r(48)(0),o=r(28),u=r(65),c=r(172),f=r(166),a=r(6),s=u.getWeak,l=Object.isExtensible,h=f.ufstore,v={},p=function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},d={get:function(t){if(a(t)){var n=s(t);return!0===n?h(this).get(t):n?n[this._i]:void 0}},set:function(t,n){return f.def(this,t,n)}},y=t.exports=r(118)("WeakMap",p,d,f,!0,!0);7!=(new y).set((Object.freeze||Object)(v),7).get(v)&&(e=f.getConstructor(p),c(e.prototype,d),u.NEED=!0,i(["delete","has","get","set"],function(t){var n=y.prototype,r=n[t];o(n,t,function(n,i){if(a(n)&&!l(n)){this._f||(this._f=new e);var o=this._f[t](n,i);return"set"==t?this:o}return r.call(this,n,i)})}))},,,,function(t,n){"use strict";function r(){var t=document.querySelector("#page-nav");if(t&&!document.querySelector("#page-nav .extend.prev")&&(t.innerHTML='<a class="extend prev disabled" rel="prev">&laquo; Prev</a>'+t.innerHTML),t&&!document.querySelector("#page-nav .extend.next")&&(t.innerHTML=t.innerHTML+'<a class="extend next disabled" rel="next">Next &raquo;</a>'),yiliaConfig&&yiliaConfig.open_in_new){document.querySelectorAll(".article-entry a:not(.article-more-a)").forEach(function(t){var n=t.getAttribute("target");n&&""!==n||t.setAttribute("target","_blank")})}if(yiliaConfig&&yiliaConfig.toc_hide_index){document.querySelectorAll(".toc-number").forEach(function(t){t.style.display="none"})}var n=document.querySelector("#js-aboutme");n&&0!==n.length&&(n.innerHTML=n.innerText)}t.exports={init:r}},function(t,n,r){"use strict";function e(t){return t&&t.__esModule?t:{default:t}}function i(t,n){var r=/\/|index.html/g;return t.replace(r,"")===n.replace(r,"")}function o(){for(var t=document.querySelectorAll(".js-header-menu li a"),n=window.location.pathname,r=0,e=t.length;r<e;r++){var o=t[r];i(n,o.getAttribute("href"))&&(0,h.default)(o,"active")}}function u(t){for(var n=t.offsetLeft,r=t.offsetParent;null!==r;)n+=r.offsetLeft,r=r.offsetParent;return n}function c(t){for(var n=t.offsetTop,r=t.offsetParent;null!==r;)n+=r.offsetTop,r=r.offsetParent;return n}function f(t,n,r,e,i){var o=u(t),f=c(t)-n;if(f-r<=i){var a=t.$newDom;a||(a=t.cloneNode(!0),(0,d.default)(t,a),t.$newDom=a,a.style.position="fixed",a.style.top=(r||f)+"px",a.style.left=o+"px",a.style.zIndex=e||2,a.style.width="100%",a.style.color="#fff"),a.style.visibility="visible",t.style.visibility="hidden"}else{t.style.visibility="visible";var s=t.$newDom;s&&(s.style.visibility="hidden")}}function a(){var t=document.querySelector(".js-overlay"),n=document.querySelector(".js-header-menu");f(t,document.body.scrollTop,-63,2,0),f(n,document.body.scrollTop,1,3,0)}function s(){document.querySelector("#container").addEventListener("scroll",function(t){a()}),window.addEventListener("scroll",function(t){a()}),a()}var l=r(156),h=e(l),v=r(157),p=(e(v),r(382)),d=e(p),y=r(128),g=e(y),b=r(190),m=e(b),x=r(129);(function(){g.default.versions.mobile&&window.screen.width<800&&(o(),s())})(),(0,x.addLoadEvent)(function(){m.default.init()}),t.exports={}},,,,function(t,n,r){(function(t){"use strict";function n(t,n,r){t[n]||Object[e](t,n,{writable:!0,configurable:!0,value:r})}if(r(381),r(391),r(198),t._babelPolyfill)throw new Error("only one instance of babel-polyfill is allowed");t._babelPolyfill=!0;var e="defineProperty";n(String.prototype,"padLeft","".padStart),n(String.prototype,"padRight","".padEnd),"pop,reverse,shift,keys,values,entries,indexOf,every,some,forEach,map,filter,find,findIndex,includes,join,slice,concat,push,splice,unshift,sort,lastIndexOf,reduce,reduceRight,copyWithin,fill".split(",").forEach(function(t){[][t]&&n(Array,t,Function.call.bind([][t]))})}).call(n,function(){return this}())},,,function(t,n,r){r(210),t.exports=r(52).RegExp.escape},,,,function(t,n,r){var e=r(6),i=r(138),o=r(7)("species");t.exports=function(t){var n;return i(t)&&(n=t.constructor,"function"!=typeof n||n!==Array&&!i(n.prototype)||(n=void 0),e(n)&&null===(n=n[o])&&(n=void 0)),void 0===n?Array:n}},function(t,n,r){var e=r(202);t.exports=function(t,n){return new(e(t))(n)}},function(t,n,r){"use strict";var e=r(2),i=r(50),o="number";t.exports=function(t){if("string"!==t&&t!==o&&"default"!==t)throw TypeError("Incorrect hint");return i(e(this),t!=o)}},function(t,n,r){var e=r(72),i=r(125),o=r(116);t.exports=function(t){var n=e(t),r=i.f;if(r)for(var u,c=r(t),f=o.f,a=0;c.length>a;)f.call(t,u=c[a++])&&n.push(u);return n}},function(t,n,r){var e=r(72),i=r(30);t.exports=function(t,n){for(var r,o=i(t),u=e(o),c=u.length,f=0;c>f;)if(o[r=u[f++]]===n)return r}},function(t,n,r){"use strict";var e=r(208),i=r(121),o=r(26);t.exports=function(){for(var t=o(this),n=arguments.length,r=Array(n),u=0,c=e._,f=!1;n>u;)(r[u]=arguments[u++])===c&&(f=!0);return function(){var e,o=this,u=arguments.length,a=0,s=0;if(!f&&!u)return i(t,r,o);if(e=r.slice(),f)for(;n>a;a++)e[a]===c&&(e[a]=arguments[s++]);for(;u>s;)e.push(arguments[s++]);return i(t,e,o)}}},function(t,n,r){t.exports=r(3)},function(t,n){t.exports=function(t,n){var r=n===Object(n)?function(t){return n[t]}:n;return function(n){return String(n).replace(t,r)}}},function(t,n,r){var e=r(1),i=r(209)(/[\\^$*+?.()|[\]{}]/g,"\\$&");e(e.S,"RegExp",{escape:function(t){return i(t)}})},function(t,n,r){var e=r(1);e(e.P,"Array",{copyWithin:r(160)}),r(78)("copyWithin")},function(t,n,r){"use strict";var e=r(1),i=r(48)(4);e(e.P+e.F*!r(47)([].every,!0),"Array",{every:function(t){return i(this,t,arguments[1])}})},function(t,n,r){var e=r(1);e(e.P,"Array",{fill:r(130)}),r(78)("fill")},function(t,n,r){"use strict";var e=r(1),i=r(48)(2);e(e.P+e.F*!r(47)([].filter,!0),"Array",{filter:function(t){return i(this,t,arguments[1])}})},function(t,n,r){"use strict";var e=r(1),i=r(48)(6),o="findIndex",u=!0;o in[]&&Array(1)[o](function(){u=!1}),e(e.P+e.F*u,"Array",{findIndex:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),r(78)(o)},function(t,n,r){"use strict";var e=r(1),i=r(48)(5),o="find",u=!0;o in[]&&Array(1)[o](function(){u=!1}),e(e.P+e.F*u,"Array",{find:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),r(78)(o)},function(t,n,r){"use strict";var e=r(1),i=r(48)(0),o=r(47)([].forEach,!0);e(e.P+e.F*!o,"Array",{forEach:function(t){return i(this,t,arguments[1])}})},function(t,n,r){"use strict";var e=r(53),i=r(1),o=r(17),u=r(169),c=r(137),f=r(16),a=r(131),s=r(154);i(i.S+i.F*!r(123)(function(t){Array.from(t)}),"Array",{from:function(t){var n,r,i,l,h=o(t),v="function"==typeof this?this:Array,p=arguments.length,d=p>1?arguments[1]:void 0,y=void 0!==d,g=0,b=s(h);if(y&&(d=e(d,p>2?arguments[2]:void 0,2)),void 0==b||v==Array&&c(b))for(n=f(h.length),r=new v(n);n>g;g++)a(r,g,y?d(h[g],g):h[g]);else for(l=b.call(h),r=new v;!(i=l.next()).done;g++)a(r,g,y?u(l,d,[i.value,g],!0):i.value);return r.length=g,r}})},function(t,n,r){"use strict";var e=r(1),i=r(117)(!1),o=[].indexOf,u=!!o&&1/[1].indexOf(1,-0)<0;e(e.P+e.F*(u||!r(47)(o)),"Array",{indexOf:function(t){return u?o.apply(this,arguments)||0:i(this,t,arguments[1])}})},function(t,n,r){var e=r(1);e(e.S,"Array",{isArray:r(138)})},function(t,n,r){"use strict";var e=r(1),i=r(30),o=[].join;e(e.P+e.F*(r(115)!=Object||!r(47)(o)),"Array",{join:function(t){return o.call(i(this),void 0===t?",":t)}})},function(t,n,r){"use strict";var e=r(1),i=r(30),o=r(67),u=r(16),c=[].lastIndexOf,f=!!c&&1/[1].lastIndexOf(1,-0)<0;e(e.P+e.F*(f||!r(47)(c)),"Array",{lastIndexOf:function(t){if(f)return c.apply(this,arguments)||0;var n=i(this),r=u(n.length),e=r-1;for(arguments.length>1&&(e=Math.min(e,o(arguments[1]))),e<0&&(e=r+e);e>=0;e--)if(e in n&&n[e]===t)return e||0;return-1}})},function(t,n,r){"use strict";var e=r(1),i=r(48)(1);e(e.P+e.F*!r(47)([].map,!0),"Array",{map:function(t){return i(this,t,arguments[1])}})},function(t,n,r){"use strict";var e=r(1),i=r(131);e(e.S+e.F*r(4)(function(){function t(){}return!(Array.of.call(t)instanceof t)}),"Array",{of:function(){for(var t=0,n=arguments.length,r=new("function"==typeof this?this:Array)(n);n>t;)i(r,t,arguments[t++]);return r.length=n,r}})},function(t,n,r){"use strict";var e=r(1),i=r(162);e(e.P+e.F*!r(47)([].reduceRight,!0),"Array",{reduceRight:function(t){return i(this,t,arguments.length,arguments[1],!0)}})},function(t,n,r){"use strict";var e=r(1),i=r(162);e(e.P+e.F*!r(47)([].reduce,!0),"Array",{reduce:function(t){return i(this,t,arguments.length,arguments[1],!1)}})},function(t,n,r){"use strict";var e=r(1),i=r(135),o=r(45),u=r(75),c=r(16),f=[].slice;e(e.P+e.F*r(4)(function(){i&&f.call(i)}),"Array",{slice:function(t,n){var r=c(this.length),e=o(this);if(n=void 0===n?r:n,"Array"==e)return f.call(this,t,n);for(var i=u(t,r),a=u(n,r),s=c(a-i),l=Array(s),h=0;h<s;h++)l[h]="String"==e?this.charAt(i+h):this[i+h];return l}})},function(t,n,r){"use strict";var e=r(1),i=r(48)(3);e(e.P+e.F*!r(47)([].some,!0),"Array",{some:function(t){return i(this,t,arguments[1])}})},function(t,n,r){"use strict";var e=r(1),i=r(26),o=r(17),u=r(4),c=[].sort,f=[1,2,3];e(e.P+e.F*(u(function(){f.sort(void 0)})||!u(function(){f.sort(null)})||!r(47)(c)),"Array",{sort:function(t){return void 0===t?c.call(o(this)):c.call(o(this),i(t))}})},function(t,n,r){r(74)("Array")},function(t,n,r){var e=r(1);e(e.S,"Date",{now:function(){return(new Date).getTime()}})},function(t,n,r){"use strict";var e=r(1),i=r(4),o=Date.prototype.getTime,u=function(t){return t>9?t:"0"+t};e(e.P+e.F*(i(function(){return"0385-07-25T07:06:39.999Z"!=new Date(-5e13-1).toISOString()})||!i(function(){new Date(NaN).toISOString()})),"Date",{toISOString:function(){
if(!isFinite(o.call(this)))throw RangeError("Invalid time value");var t=this,n=t.getUTCFullYear(),r=t.getUTCMilliseconds(),e=n<0?"-":n>9999?"+":"";return e+("00000"+Math.abs(n)).slice(e?-6:-4)+"-"+u(t.getUTCMonth()+1)+"-"+u(t.getUTCDate())+"T"+u(t.getUTCHours())+":"+u(t.getUTCMinutes())+":"+u(t.getUTCSeconds())+"."+(r>99?r:"0"+u(r))+"Z"}})},function(t,n,r){"use strict";var e=r(1),i=r(17),o=r(50);e(e.P+e.F*r(4)(function(){return null!==new Date(NaN).toJSON()||1!==Date.prototype.toJSON.call({toISOString:function(){return 1}})}),"Date",{toJSON:function(t){var n=i(this),r=o(n);return"number"!=typeof r||isFinite(r)?n.toISOString():null}})},function(t,n,r){var e=r(7)("toPrimitive"),i=Date.prototype;e in i||r(27)(i,e,r(204))},function(t,n,r){var e=Date.prototype,i="Invalid Date",o="toString",u=e[o],c=e.getTime;new Date(NaN)+""!=i&&r(28)(e,o,function(){var t=c.call(this);return t===t?u.call(this):i})},function(t,n,r){var e=r(1);e(e.P,"Function",{bind:r(163)})},function(t,n,r){"use strict";var e=r(6),i=r(32),o=r(7)("hasInstance"),u=Function.prototype;o in u||r(11).f(u,o,{value:function(t){if("function"!=typeof this||!e(t))return!1;if(!e(this.prototype))return t instanceof this;for(;t=i(t);)if(this.prototype===t)return!0;return!1}})},function(t,n,r){var e=r(11).f,i=r(66),o=r(24),u=Function.prototype,c="name",f=Object.isExtensible||function(){return!0};c in u||r(10)&&e(u,c,{configurable:!0,get:function(){try{var t=this,n=(""+t).match(/^\s*function ([^ (]*)/)[1];return o(t,c)||!f(t)||e(t,c,i(5,n)),n}catch(t){return""}}})},function(t,n,r){var e=r(1),i=r(171),o=Math.sqrt,u=Math.acosh;e(e.S+e.F*!(u&&710==Math.floor(u(Number.MAX_VALUE))&&u(1/0)==1/0),"Math",{acosh:function(t){return(t=+t)<1?NaN:t>94906265.62425156?Math.log(t)+Math.LN2:i(t-1+o(t-1)*o(t+1))}})},function(t,n,r){function e(t){return isFinite(t=+t)&&0!=t?t<0?-e(-t):Math.log(t+Math.sqrt(t*t+1)):t}var i=r(1),o=Math.asinh;i(i.S+i.F*!(o&&1/o(0)>0),"Math",{asinh:e})},function(t,n,r){var e=r(1),i=Math.atanh;e(e.S+e.F*!(i&&1/i(-0)<0),"Math",{atanh:function(t){return 0==(t=+t)?t:Math.log((1+t)/(1-t))/2}})},function(t,n,r){var e=r(1),i=r(142);e(e.S,"Math",{cbrt:function(t){return i(t=+t)*Math.pow(Math.abs(t),1/3)}})},function(t,n,r){var e=r(1);e(e.S,"Math",{clz32:function(t){return(t>>>=0)?31-Math.floor(Math.log(t+.5)*Math.LOG2E):32}})},function(t,n,r){var e=r(1),i=Math.exp;e(e.S,"Math",{cosh:function(t){return(i(t=+t)+i(-t))/2}})},function(t,n,r){var e=r(1),i=r(141);e(e.S+e.F*(i!=Math.expm1),"Math",{expm1:i})},function(t,n,r){var e=r(1),i=r(142),o=Math.pow,u=o(2,-52),c=o(2,-23),f=o(2,127)*(2-c),a=o(2,-126),s=function(t){return t+1/u-1/u};e(e.S,"Math",{fround:function(t){var n,r,e=Math.abs(t),o=i(t);return e<a?o*s(e/a/c)*a*c:(n=(1+c/u)*e,r=n-(n-e),r>f||r!=r?o*(1/0):o*r)}})},function(t,n,r){var e=r(1),i=Math.abs;e(e.S,"Math",{hypot:function(t,n){for(var r,e,o=0,u=0,c=arguments.length,f=0;u<c;)r=i(arguments[u++]),f<r?(e=f/r,o=o*e*e+1,f=r):r>0?(e=r/f,o+=e*e):o+=r;return f===1/0?1/0:f*Math.sqrt(o)}})},function(t,n,r){var e=r(1),i=Math.imul;e(e.S+e.F*r(4)(function(){return-5!=i(4294967295,5)||2!=i.length}),"Math",{imul:function(t,n){var r=65535,e=+t,i=+n,o=r&e,u=r&i;return 0|o*u+((r&e>>>16)*u+o*(r&i>>>16)<<16>>>0)}})},function(t,n,r){var e=r(1);e(e.S,"Math",{log10:function(t){return Math.log(t)/Math.LN10}})},function(t,n,r){var e=r(1);e(e.S,"Math",{log1p:r(171)})},function(t,n,r){var e=r(1);e(e.S,"Math",{log2:function(t){return Math.log(t)/Math.LN2}})},function(t,n,r){var e=r(1);e(e.S,"Math",{sign:r(142)})},function(t,n,r){var e=r(1),i=r(141),o=Math.exp;e(e.S+e.F*r(4)(function(){return-2e-17!=!Math.sinh(-2e-17)}),"Math",{sinh:function(t){return Math.abs(t=+t)<1?(i(t)-i(-t))/2:(o(t-1)-o(-t-1))*(Math.E/2)}})},function(t,n,r){var e=r(1),i=r(141),o=Math.exp;e(e.S,"Math",{tanh:function(t){var n=i(t=+t),r=i(-t);return n==1/0?1:r==1/0?-1:(n-r)/(o(t)+o(-t))}})},function(t,n,r){var e=r(1);e(e.S,"Math",{trunc:function(t){return(t>0?Math.floor:Math.ceil)(t)}})},function(t,n,r){"use strict";var e=r(3),i=r(24),o=r(45),u=r(136),c=r(50),f=r(4),a=r(71).f,s=r(31).f,l=r(11).f,h=r(82).trim,v="Number",p=e[v],d=p,y=p.prototype,g=o(r(70)(y))==v,b="trim"in String.prototype,m=function(t){var n=c(t,!1);if("string"==typeof n&&n.length>2){n=b?n.trim():h(n,3);var r,e,i,o=n.charCodeAt(0);if(43===o||45===o){if(88===(r=n.charCodeAt(2))||120===r)return NaN}else if(48===o){switch(n.charCodeAt(1)){case 66:case 98:e=2,i=49;break;case 79:case 111:e=8,i=55;break;default:return+n}for(var u,f=n.slice(2),a=0,s=f.length;a<s;a++)if((u=f.charCodeAt(a))<48||u>i)return NaN;return parseInt(f,e)}}return+n};if(!p(" 0o1")||!p("0b1")||p("+0x1")){p=function(t){var n=arguments.length<1?0:t,r=this;return r instanceof p&&(g?f(function(){y.valueOf.call(r)}):o(r)!=v)?u(new d(m(n)),r,p):m(n)};for(var x,w=r(10)?a(d):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger".split(","),S=0;w.length>S;S++)i(d,x=w[S])&&!i(p,x)&&l(p,x,s(d,x));p.prototype=y,y.constructor=p,r(28)(e,v,p)}},function(t,n,r){var e=r(1);e(e.S,"Number",{EPSILON:Math.pow(2,-52)})},function(t,n,r){var e=r(1),i=r(3).isFinite;e(e.S,"Number",{isFinite:function(t){return"number"==typeof t&&i(t)}})},function(t,n,r){var e=r(1);e(e.S,"Number",{isInteger:r(168)})},function(t,n,r){var e=r(1);e(e.S,"Number",{isNaN:function(t){return t!=t}})},function(t,n,r){var e=r(1),i=r(168),o=Math.abs;e(e.S,"Number",{isSafeInteger:function(t){return i(t)&&o(t)<=9007199254740991}})},function(t,n,r){var e=r(1);e(e.S,"Number",{MAX_SAFE_INTEGER:9007199254740991})},function(t,n,r){var e=r(1);e(e.S,"Number",{MIN_SAFE_INTEGER:-9007199254740991})},function(t,n,r){var e=r(1),i=r(178);e(e.S+e.F*(Number.parseFloat!=i),"Number",{parseFloat:i})},function(t,n,r){var e=r(1),i=r(179);e(e.S+e.F*(Number.parseInt!=i),"Number",{parseInt:i})},function(t,n,r){"use strict";var e=r(1),i=r(67),o=r(159),u=r(149),c=1..toFixed,f=Math.floor,a=[0,0,0,0,0,0],s="Number.toFixed: incorrect invocation!",l="0",h=function(t,n){for(var r=-1,e=n;++r<6;)e+=t*a[r],a[r]=e%1e7,e=f(e/1e7)},v=function(t){for(var n=6,r=0;--n>=0;)r+=a[n],a[n]=f(r/t),r=r%t*1e7},p=function(){for(var t=6,n="";--t>=0;)if(""!==n||0===t||0!==a[t]){var r=String(a[t]);n=""===n?r:n+u.call(l,7-r.length)+r}return n},d=function(t,n,r){return 0===n?r:n%2==1?d(t,n-1,r*t):d(t*t,n/2,r)},y=function(t){for(var n=0,r=t;r>=4096;)n+=12,r/=4096;for(;r>=2;)n+=1,r/=2;return n};e(e.P+e.F*(!!c&&("0.000"!==8e-5.toFixed(3)||"1"!==.9.toFixed(0)||"1.25"!==1.255.toFixed(2)||"1000000000000000128"!==(0xde0b6b3a7640080).toFixed(0))||!r(4)(function(){c.call({})})),"Number",{toFixed:function(t){var n,r,e,c,f=o(this,s),a=i(t),g="",b=l;if(a<0||a>20)throw RangeError(s);if(f!=f)return"NaN";if(f<=-1e21||f>=1e21)return String(f);if(f<0&&(g="-",f=-f),f>1e-21)if(n=y(f*d(2,69,1))-69,r=n<0?f*d(2,-n,1):f/d(2,n,1),r*=4503599627370496,(n=52-n)>0){for(h(0,r),e=a;e>=7;)h(1e7,0),e-=7;for(h(d(10,e,1),0),e=n-1;e>=23;)v(1<<23),e-=23;v(1<<e),h(1,1),v(2),b=p()}else h(0,r),h(1<<-n,0),b=p()+u.call(l,a);return a>0?(c=b.length,b=g+(c<=a?"0."+u.call(l,a-c)+b:b.slice(0,c-a)+"."+b.slice(c-a))):b=g+b,b}})},function(t,n,r){"use strict";var e=r(1),i=r(4),o=r(159),u=1..toPrecision;e(e.P+e.F*(i(function(){return"1"!==u.call(1,void 0)})||!i(function(){u.call({})})),"Number",{toPrecision:function(t){var n=o(this,"Number#toPrecision: incorrect invocation!");return void 0===t?u.call(n):u.call(n,t)}})},function(t,n,r){var e=r(1);e(e.S+e.F,"Object",{assign:r(172)})},function(t,n,r){var e=r(1);e(e.S,"Object",{create:r(70)})},function(t,n,r){var e=r(1);e(e.S+e.F*!r(10),"Object",{defineProperties:r(173)})},function(t,n,r){var e=r(1);e(e.S+e.F*!r(10),"Object",{defineProperty:r(11).f})},function(t,n,r){var e=r(6),i=r(65).onFreeze;r(49)("freeze",function(t){return function(n){return t&&e(n)?t(i(n)):n}})},function(t,n,r){var e=r(30),i=r(31).f;r(49)("getOwnPropertyDescriptor",function(){return function(t,n){return i(e(t),n)}})},function(t,n,r){r(49)("getOwnPropertyNames",function(){return r(174).f})},function(t,n,r){var e=r(17),i=r(32);r(49)("getPrototypeOf",function(){return function(t){return i(e(t))}})},function(t,n,r){var e=r(6);r(49)("isExtensible",function(t){return function(n){return!!e(n)&&(!t||t(n))}})},function(t,n,r){var e=r(6);r(49)("isFrozen",function(t){return function(n){return!e(n)||!!t&&t(n)}})},function(t,n,r){var e=r(6);r(49)("isSealed",function(t){return function(n){return!e(n)||!!t&&t(n)}})},function(t,n,r){var e=r(1);e(e.S,"Object",{is:r(180)})},function(t,n,r){var e=r(17),i=r(72);r(49)("keys",function(){return function(t){return i(e(t))}})},function(t,n,r){var e=r(6),i=r(65).onFreeze;r(49)("preventExtensions",function(t){return function(n){return t&&e(n)?t(i(n)):n}})},function(t,n,r){var e=r(6),i=r(65).onFreeze;r(49)("seal",function(t){return function(n){return t&&e(n)?t(i(n)):n}})},function(t,n,r){var e=r(1);e(e.S,"Object",{setPrototypeOf:r(144).set})},function(t,n,r){"use strict";var e=r(114),i={};i[r(7)("toStringTag")]="z",i+""!="[object z]"&&r(28)(Object.prototype,"toString",function(){return"[object "+e(this)+"]"},!0)},function(t,n,r){var e=r(1),i=r(178);e(e.G+e.F*(parseFloat!=i),{parseFloat:i})},function(t,n,r){var e=r(1),i=r(179);e(e.G+e.F*(parseInt!=i),{parseInt:i})},function(t,n,r){"use strict";var e,i,o,u=r(69),c=r(3),f=r(53),a=r(114),s=r(1),l=r(6),h=r(26),v=r(68),p=r(79),d=r(146),y=r(151).set,g=r(143)(),b="Promise",m=c.TypeError,x=c.process,w=c[b],x=c.process,S="process"==a(x),_=function(){},O=!!function(){try{var t=w.resolve(1),n=(t.constructor={})[r(7)("species")]=function(t){t(_,_)};return(S||"function"==typeof PromiseRejectionEvent)&&t.then(_)instanceof n}catch(t){}}(),E=function(t,n){return t===n||t===w&&n===o},P=function(t){var n;return!(!l(t)||"function"!=typeof(n=t.then))&&n},j=function(t){return E(w,t)?new F(t):new i(t)},F=i=function(t){var n,r;this.promise=new t(function(t,e){if(void 0!==n||void 0!==r)throw m("Bad Promise constructor");n=t,r=e}),this.resolve=h(n),this.reject=h(r)},M=function(t){try{t()}catch(t){return{error:t}}},A=function(t,n){if(!t._n){t._n=!0;var r=t._c;g(function(){for(var e=t._v,i=1==t._s,o=0;r.length>o;)!function(n){var r,o,u=i?n.ok:n.fail,c=n.resolve,f=n.reject,a=n.domain;try{u?(i||(2==t._h&&I(t),t._h=1),!0===u?r=e:(a&&a.enter(),r=u(e),a&&a.exit()),r===n.promise?f(m("Promise-chain cycle")):(o=P(r))?o.call(r,c,f):c(r)):f(e)}catch(t){f(t)}}(r[o++]);t._c=[],t._n=!1,n&&!t._h&&N(t)})}},N=function(t){y.call(c,function(){var n,r,e,i=t._v;if(T(t)&&(n=M(function(){S?x.emit("unhandledRejection",i,t):(r=c.onunhandledrejection)?r({promise:t,reason:i}):(e=c.console)&&e.error&&e.error("Unhandled promise rejection",i)}),t._h=S||T(t)?2:1),t._a=void 0,n)throw n.error})},T=function(t){if(1==t._h)return!1;for(var n,r=t._a||t._c,e=0;r.length>e;)if(n=r[e++],n.fail||!T(n.promise))return!1;return!0},I=function(t){y.call(c,function(){var n;S?x.emit("rejectionHandled",t):(n=c.onrejectionhandled)&&n({promise:t,reason:t._v})})},k=function(t){var n=this;n._d||(n._d=!0,n=n._w||n,n._v=t,n._s=2,n._a||(n._a=n._c.slice()),A(n,!0))},L=function(t){var n,r=this;if(!r._d){r._d=!0,r=r._w||r;try{if(r===t)throw m("Promise can't be resolved itself");(n=P(t))?g(function(){var e={_w:r,_d:!1};try{n.call(t,f(L,e,1),f(k,e,1))}catch(t){k.call(e,t)}}):(r._v=t,r._s=1,A(r,!1))}catch(t){k.call({_w:r,_d:!1},t)}}};O||(w=function(t){v(this,w,b,"_h"),h(t),e.call(this);try{t(f(L,this,1),f(k,this,1))}catch(t){k.call(this,t)}},e=function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},e.prototype=r(73)(w.prototype,{then:function(t,n){var r=j(d(this,w));return r.ok="function"!=typeof t||t,r.fail="function"==typeof n&&n,r.domain=S?x.domain:void 0,this._c.push(r),this._a&&this._a.push(r),this._s&&A(this,!1),r.promise},catch:function(t){return this.then(void 0,t)}}),F=function(){var t=new e;this.promise=t,this.resolve=f(L,t,1),this.reject=f(k,t,1)}),s(s.G+s.W+s.F*!O,{Promise:w}),r(81)(w,b),r(74)(b),o=r(52)[b],s(s.S+s.F*!O,b,{reject:function(t){var n=j(this);return(0,n.reject)(t),n.promise}}),s(s.S+s.F*(u||!O),b,{resolve:function(t){if(t instanceof w&&E(t.constructor,this))return t;var n=j(this);return(0,n.resolve)(t),n.promise}}),s(s.S+s.F*!(O&&r(123)(function(t){w.all(t).catch(_)})),b,{all:function(t){var n=this,r=j(n),e=r.resolve,i=r.reject,o=M(function(){var r=[],o=0,u=1;p(t,!1,function(t){var c=o++,f=!1;r.push(void 0),u++,n.resolve(t).then(function(t){f||(f=!0,r[c]=t,--u||e(r))},i)}),--u||e(r)});return o&&i(o.error),r.promise},race:function(t){var n=this,r=j(n),e=r.reject,i=M(function(){p(t,!1,function(t){n.resolve(t).then(r.resolve,e)})});return i&&e(i.error),r.promise}})},function(t,n,r){var e=r(1),i=r(26),o=r(2),u=(r(3).Reflect||{}).apply,c=Function.apply;e(e.S+e.F*!r(4)(function(){u(function(){})}),"Reflect",{apply:function(t,n,r){var e=i(t),f=o(r);return u?u(e,n,f):c.call(e,n,f)}})},function(t,n,r){var e=r(1),i=r(70),o=r(26),u=r(2),c=r(6),f=r(4),a=r(163),s=(r(3).Reflect||{}).construct,l=f(function(){function t(){}return!(s(function(){},[],t)instanceof t)}),h=!f(function(){s(function(){})});e(e.S+e.F*(l||h),"Reflect",{construct:function(t,n){o(t),u(n);var r=arguments.length<3?t:o(arguments[2]);if(h&&!l)return s(t,n,r);if(t==r){switch(n.length){case 0:return new t;case 1:return new t(n[0]);case 2:return new t(n[0],n[1]);case 3:return new t(n[0],n[1],n[2]);case 4:return new t(n[0],n[1],n[2],n[3])}var e=[null];return e.push.apply(e,n),new(a.apply(t,e))}var f=r.prototype,v=i(c(f)?f:Object.prototype),p=Function.apply.call(t,v,n);return c(p)?p:v}})},function(t,n,r){var e=r(11),i=r(1),o=r(2),u=r(50);i(i.S+i.F*r(4)(function(){Reflect.defineProperty(e.f({},1,{value:1}),1,{value:2})}),"Reflect",{defineProperty:function(t,n,r){o(t),n=u(n,!0),o(r);try{return e.f(t,n,r),!0}catch(t){return!1}}})},function(t,n,r){var e=r(1),i=r(31).f,o=r(2);e(e.S,"Reflect",{deleteProperty:function(t,n){var r=i(o(t),n);return!(r&&!r.configurable)&&delete t[n]}})},function(t,n,r){"use strict";var e=r(1),i=r(2),o=function(t){this._t=i(t),this._i=0;var n,r=this._k=[];for(n in t)r.push(n)};r(139)(o,"Object",function(){var t,n=this,r=n._k;do{if(n._i>=r.length)return{value:void 0,done:!0}}while(!((t=r[n._i++])in n._t));return{value:t,done:!1}}),e(e.S,"Reflect",{enumerate:function(t){return new o(t)}})},function(t,n,r){var e=r(31),i=r(1),o=r(2);i(i.S,"Reflect",{getOwnPropertyDescriptor:function(t,n){return e.f(o(t),n)}})},function(t,n,r){var e=r(1),i=r(32),o=r(2);e(e.S,"Reflect",{getPrototypeOf:function(t){return i(o(t))}})},function(t,n,r){function e(t,n){var r,c,s=arguments.length<3?t:arguments[2];return a(t)===s?t[n]:(r=i.f(t,n))?u(r,"value")?r.value:void 0!==r.get?r.get.call(s):void 0:f(c=o(t))?e(c,n,s):void 0}var i=r(31),o=r(32),u=r(24),c=r(1),f=r(6),a=r(2);c(c.S,"Reflect",{get:e})},function(t,n,r){var e=r(1);e(e.S,"Reflect",{has:function(t,n){return n in t}})},function(t,n,r){var e=r(1),i=r(2),o=Object.isExtensible;e(e.S,"Reflect",{isExtensible:function(t){return i(t),!o||o(t)}})},function(t,n,r){var e=r(1);e(e.S,"Reflect",{ownKeys:r(177)})},function(t,n,r){var e=r(1),i=r(2),o=Object.preventExtensions;e(e.S,"Reflect",{preventExtensions:function(t){i(t);try{return o&&o(t),!0}catch(t){return!1}}})},function(t,n,r){var e=r(1),i=r(144);i&&e(e.S,"Reflect",{setPrototypeOf:function(t,n){i.check(t,n);try{return i.set(t,n),!0}catch(t){return!1}}})},function(t,n,r){function e(t,n,r){var f,h,v=arguments.length<4?t:arguments[3],p=o.f(s(t),n);if(!p){if(l(h=u(t)))return e(h,n,r,v);p=a(0)}return c(p,"value")?!(!1===p.writable||!l(v)||(f=o.f(v,n)||a(0),f.value=r,i.f(v,n,f),0)):void 0!==p.set&&(p.set.call(v,r),!0)}var i=r(11),o=r(31),u=r(32),c=r(24),f=r(1),a=r(66),s=r(2),l=r(6);f(f.S,"Reflect",{set:e})},function(t,n,r){var e=r(3),i=r(136),o=r(11).f,u=r(71).f,c=r(122),f=r(120),a=e.RegExp,s=a,l=a.prototype,h=/a/g,v=/a/g,p=new a(h)!==h;if(r(10)&&(!p||r(4)(function(){return v[r(7)("match")]=!1,a(h)!=h||a(v)==v||"/a/i"!=a(h,"i")}))){a=function(t,n){var r=this instanceof a,e=c(t),o=void 0===n;return!r&&e&&t.constructor===a&&o?t:i(p?new s(e&&!o?t.source:t,n):s((e=t instanceof a)?t.source:t,e&&o?f.call(t):n),r?this:l,a)};for(var d=u(s),y=0;d.length>y;)!function(t){t in a||o(a,t,{configurable:!0,get:function(){return s[t]},set:function(n){s[t]=n}})}(d[y++]);l.constructor=a,a.prototype=l,r(28)(e,"RegExp",a)}r(74)("RegExp")},function(t,n,r){r(119)("match",1,function(t,n,r){return[function(r){"use strict";var e=t(this),i=void 0==r?void 0:r[n];return void 0!==i?i.call(r,e):new RegExp(r)[n](String(e))},r]})},function(t,n,r){r(119)("replace",2,function(t,n,r){return[function(e,i){"use strict";var o=t(this),u=void 0==e?void 0:e[n];return void 0!==u?u.call(e,o,i):r.call(String(o),e,i)},r]})},function(t,n,r){r(119)("search",1,function(t,n,r){return[function(r){"use strict";var e=t(this),i=void 0==r?void 0:r[n];return void 0!==i?i.call(r,e):new RegExp(r)[n](String(e))},r]})},function(t,n,r){r(119)("split",2,function(t,n,e){"use strict";var i=r(122),o=e,u=[].push,c="split",f="length",a="lastIndex";if("c"=="abbc"[c](/(b)*/)[1]||4!="test"[c](/(?:)/,-1)[f]||2!="ab"[c](/(?:ab)*/)[f]||4!="."[c](/(.?)(.?)/)[f]||"."[c](/()()/)[f]>1||""[c](/.?/)[f]){var s=void 0===/()??/.exec("")[1];e=function(t,n){var r=String(this);if(void 0===t&&0===n)return[];if(!i(t))return o.call(r,t,n);var e,c,l,h,v,p=[],d=(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.unicode?"u":"")+(t.sticky?"y":""),y=0,g=void 0===n?4294967295:n>>>0,b=new RegExp(t.source,d+"g");for(s||(e=new RegExp("^"+b.source+"$(?!\\s)",d));(c=b.exec(r))&&!((l=c.index+c[0][f])>y&&(p.push(r.slice(y,c.index)),!s&&c[f]>1&&c[0].replace(e,function(){for(v=1;v<arguments[f]-2;v++)void 0===arguments[v]&&(c[v]=void 0)}),c[f]>1&&c.index<r[f]&&u.apply(p,c.slice(1)),h=c[0][f],y=l,p[f]>=g));)b[a]===c.index&&b[a]++;return y===r[f]?!h&&b.test("")||p.push(""):p.push(r.slice(y)),p[f]>g?p.slice(0,g):p}}else"0"[c](void 0,0)[f]&&(e=function(t,n){return void 0===t&&0===n?[]:o.call(this,t,n)});return[function(r,i){var o=t(this),u=void 0==r?void 0:r[n];return void 0!==u?u.call(r,o,i):e.call(String(o),r,i)},e]})},function(t,n,r){"use strict";r(184);var e=r(2),i=r(120),o=r(10),u="toString",c=/./[u],f=function(t){r(28)(RegExp.prototype,u,t,!0)};r(4)(function(){return"/a/b"!=c.call({source:"a",flags:"b"})})?f(function(){var t=e(this);return"/".concat(t.source,"/","flags"in t?t.flags:!o&&t instanceof RegExp?i.call(t):void 0)}):c.name!=u&&f(function(){return c.call(this)})},function(t,n,r){"use strict";r(29)("anchor",function(t){return function(n){return t(this,"a","name",n)}})},function(t,n,r){"use strict";r(29)("big",function(t){return function(){return t(this,"big","","")}})},function(t,n,r){"use strict";r(29)("blink",function(t){return function(){return t(this,"blink","","")}})},function(t,n,r){"use strict";r(29)("bold",function(t){return function(){return t(this,"b","","")}})},function(t,n,r){"use strict";var e=r(1),i=r(147)(!1);e(e.P,"String",{codePointAt:function(t){return i(this,t)}})},function(t,n,r){"use strict";var e=r(1),i=r(16),o=r(148),u="endsWith",c=""[u];e(e.P+e.F*r(134)(u),"String",{endsWith:function(t){var n=o(this,t,u),r=arguments.length>1?arguments[1]:void 0,e=i(n.length),f=void 0===r?e:Math.min(i(r),e),a=String(t);return c?c.call(n,a,f):n.slice(f-a.length,f)===a}})},function(t,n,r){"use strict";r(29)("fixed",function(t){return function(){return t(this,"tt","","")}})},function(t,n,r){"use strict";r(29)("fontcolor",function(t){return function(n){return t(this,"font","color",n)}})},function(t,n,r){"use strict";r(29)("fontsize",function(t){return function(n){return t(this,"font","size",n)}})},function(t,n,r){var e=r(1),i=r(75),o=String.fromCharCode,u=String.fromCodePoint;e(e.S+e.F*(!!u&&1!=u.length),"String",{fromCodePoint:function(t){for(var n,r=[],e=arguments.length,u=0;e>u;){if(n=+arguments[u++],i(n,1114111)!==n)throw RangeError(n+" is not a valid code point");r.push(n<65536?o(n):o(55296+((n-=65536)>>10),n%1024+56320))}return r.join("")}})},function(t,n,r){"use strict";var e=r(1),i=r(148),o="includes";e(e.P+e.F*r(134)(o),"String",{includes:function(t){return!!~i(this,t,o).indexOf(t,arguments.length>1?arguments[1]:void 0)}})},function(t,n,r){"use strict";r(29)("italics",function(t){return function(){return t(this,"i","","")}})},function(t,n,r){"use strict";var e=r(147)(!0);r(140)(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,n=this._t,r=this._i;return r>=n.length?{value:void 0,done:!0}:(t=e(n,r),this._i+=t.length,{value:t,done:!1})})},function(t,n,r){"use strict";r(29)("link",function(t){return function(n){return t(this,"a","href",n)}})},function(t,n,r){var e=r(1),i=r(30),o=r(16);e(e.S,"String",{raw:function(t){for(var n=i(t.raw),r=o(n.length),e=arguments.length,u=[],c=0;r>c;)u.push(String(n[c++])),c<e&&u.push(String(arguments[c]));return u.join("")}})},function(t,n,r){var e=r(1);e(e.P,"String",{repeat:r(149)})},function(t,n,r){"use strict";r(29)("small",function(t){return function(){return t(this,"small","","")}})},function(t,n,r){"use strict";var e=r(1),i=r(16),o=r(148),u="startsWith",c=""[u];e(e.P+e.F*r(134)(u),"String",{startsWith:function(t){var n=o(this,t,u),r=i(Math.min(arguments.length>1?arguments[1]:void 0,n.length)),e=String(t);return c?c.call(n,e,r):n.slice(r,r+e.length)===e}})},function(t,n,r){"use strict";r(29)("strike",function(t){return function(){return t(this,"strike","","")}})},function(t,n,r){"use strict";r(29)("sub",function(t){return function(){return t(this,"sub","","")}})},function(t,n,r){"use strict";r(29)("sup",function(t){return function(){return t(this,"sup","","")}})},function(t,n,r){"use strict";r(82)("trim",function(t){return function(){return t(this,3)}})},function(t,n,r){"use strict";var e=r(3),i=r(24),o=r(10),u=r(1),c=r(28),f=r(65).KEY,a=r(4),s=r(126),l=r(81),h=r(76),v=r(7),p=r(182),d=r(153),y=r(206),g=r(205),b=r(138),m=r(2),x=r(30),w=r(50),S=r(66),_=r(70),O=r(174),E=r(31),P=r(11),j=r(72),F=E.f,M=P.f,A=O.f,N=e.Symbol,T=e.JSON,I=T&&T.stringify,k="prototype",L=v("_hidden"),R=v("toPrimitive"),C={}.propertyIsEnumerable,D=s("symbol-registry"),U=s("symbols"),W=s("op-symbols"),G=Object[k],B="function"==typeof N,V=e.QObject,z=!V||!V[k]||!V[k].findChild,q=o&&a(function(){return 7!=_(M({},"a",{get:function(){return M(this,"a",{value:7}).a}})).a})?function(t,n,r){var e=F(G,n);e&&delete G[n],M(t,n,r),e&&t!==G&&M(G,n,e)}:M,K=function(t){var n=U[t]=_(N[k]);return n._k=t,n},J=B&&"symbol"==typeof N.iterator?function(t){return"symbol"==typeof t}:function(t){return t instanceof N},Y=function(t,n,r){return t===G&&Y(W,n,r),m(t),n=w(n,!0),m(r),i(U,n)?(r.enumerable?(i(t,L)&&t[L][n]&&(t[L][n]=!1),r=_(r,{enumerable:S(0,!1)})):(i(t,L)||M(t,L,S(1,{})),t[L][n]=!0),q(t,n,r)):M(t,n,r)},H=function(t,n){m(t);for(var r,e=g(n=x(n)),i=0,o=e.length;o>i;)Y(t,r=e[i++],n[r]);return t},$=function(t,n){return void 0===n?_(t):H(_(t),n)},X=function(t){var n=C.call(this,t=w(t,!0));return!(this===G&&i(U,t)&&!i(W,t))&&(!(n||!i(this,t)||!i(U,t)||i(this,L)&&this[L][t])||n)},Q=function(t,n){if(t=x(t),n=w(n,!0),t!==G||!i(U,n)||i(W,n)){var r=F(t,n);return!r||!i(U,n)||i(t,L)&&t[L][n]||(r.enumerable=!0),r}},Z=function(t){for(var n,r=A(x(t)),e=[],o=0;r.length>o;)i(U,n=r[o++])||n==L||n==f||e.push(n);return e},tt=function(t){for(var n,r=t===G,e=A(r?W:x(t)),o=[],u=0;e.length>u;)!i(U,n=e[u++])||r&&!i(G,n)||o.push(U[n]);return o};B||(N=function(){if(this instanceof N)throw TypeError("Symbol is not a constructor!");var t=h(arguments.length>0?arguments[0]:void 0),n=function(r){this===G&&n.call(W,r),i(this,L)&&i(this[L],t)&&(this[L][t]=!1),q(this,t,S(1,r))};return o&&z&&q(G,t,{configurable:!0,set:n}),K(t)},c(N[k],"toString",function(){return this._k}),E.f=Q,P.f=Y,r(71).f=O.f=Z,r(116).f=X,r(125).f=tt,o&&!r(69)&&c(G,"propertyIsEnumerable",X,!0),p.f=function(t){return K(v(t))}),u(u.G+u.W+u.F*!B,{Symbol:N});for(var nt="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),rt=0;nt.length>rt;)v(nt[rt++]);for(var nt=j(v.store),rt=0;nt.length>rt;)d(nt[rt++]);u(u.S+u.F*!B,"Symbol",{for:function(t){return i(D,t+="")?D[t]:D[t]=N(t)},keyFor:function(t){if(J(t))return y(D,t);throw TypeError(t+" is not a symbol!")},useSetter:function(){z=!0},useSimple:function(){z=!1}}),u(u.S+u.F*!B,"Object",{create:$,defineProperty:Y,defineProperties:H,getOwnPropertyDescriptor:Q,getOwnPropertyNames:Z,getOwnPropertySymbols:tt}),T&&u(u.S+u.F*(!B||a(function(){var t=N();return"[null]"!=I([t])||"{}"!=I({a:t})||"{}"!=I(Object(t))})),"JSON",{stringify:function(t){if(void 0!==t&&!J(t)){for(var n,r,e=[t],i=1;arguments.length>i;)e.push(arguments[i++]);return n=e[1],"function"==typeof n&&(r=n),!r&&b(n)||(n=function(t,n){if(r&&(n=r.call(this,t,n)),!J(n))return n}),e[1]=n,I.apply(T,e)}}}),N[k][R]||r(27)(N[k],R,N[k].valueOf),l(N,"Symbol"),l(Math,"Math",!0),l(e.JSON,"JSON",!0)},function(t,n,r){"use strict";var e=r(1),i=r(127),o=r(152),u=r(2),c=r(75),f=r(16),a=r(6),s=r(3).ArrayBuffer,l=r(146),h=o.ArrayBuffer,v=o.DataView,p=i.ABV&&s.isView,d=h.prototype.slice,y=i.VIEW,g="ArrayBuffer";e(e.G+e.W+e.F*(s!==h),{ArrayBuffer:h}),e(e.S+e.F*!i.CONSTR,g,{isView:function(t){return p&&p(t)||a(t)&&y in t}}),e(e.P+e.U+e.F*r(4)(function(){return!new h(2).slice(1,void 0).byteLength}),g,{slice:function(t,n){if(void 0!==d&&void 0===n)return d.call(u(this),t);for(var r=u(this).byteLength,e=c(t,r),i=c(void 0===n?r:n,r),o=new(l(this,h))(f(i-e)),a=new v(this),s=new v(o),p=0;e<i;)s.setUint8(p++,a.getUint8(e++));return o}}),r(74)(g)},function(t,n,r){var e=r(1);e(e.G+e.W+e.F*!r(127).ABV,{DataView:r(152).DataView})},function(t,n,r){r(55)("Float32",4,function(t){return function(n,r,e){return t(this,n,r,e)}})},function(t,n,r){r(55)("Float64",8,function(t){return function(n,r,e){return t(this,n,r,e)}})},function(t,n,r){r(55)("Int16",2,function(t){return function(n,r,e){return t(this,n,r,e)}})},function(t,n,r){r(55)("Int32",4,function(t){return function(n,r,e){return t(this,n,r,e)}})},function(t,n,r){r(55)("Int8",1,function(t){return function(n,r,e){return t(this,n,r,e)}})},function(t,n,r){r(55)("Uint16",2,function(t){return function(n,r,e){return t(this,n,r,e)}})},function(t,n,r){r(55)("Uint32",4,function(t){return function(n,r,e){return t(this,n,r,e)}})},function(t,n,r){r(55)("Uint8",1,function(t){return function(n,r,e){return t(this,n,r,e)}})},function(t,n,r){r(55)("Uint8",1,function(t){return function(n,r,e){return t(this,n,r,e)}},!0)},function(t,n,r){"use strict";var e=r(166);r(118)("WeakSet",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},{add:function(t){return e.def(this,t,!0)}},e,!1,!0)},function(t,n,r){"use strict";var e=r(1),i=r(117)(!0);e(e.P,"Array",{includes:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),r(78)("includes")},function(t,n,r){var e=r(1),i=r(143)(),o=r(3).process,u="process"==r(45)(o);e(e.G,{asap:function(t){var n=u&&o.domain;i(n?n.bind(t):t)}})},function(t,n,r){var e=r(1),i=r(45);e(e.S,"Error",{isError:function(t){return"Error"===i(t)}})},function(t,n,r){var e=r(1);e(e.P+e.R,"Map",{toJSON:r(165)("Map")})},function(t,n,r){var e=r(1);e(e.S,"Math",{iaddh:function(t,n,r,e){var i=t>>>0,o=n>>>0,u=r>>>0;return o+(e>>>0)+((i&u|(i|u)&~(i+u>>>0))>>>31)|0}})},function(t,n,r){var e=r(1);e(e.S,"Math",{imulh:function(t,n){var r=65535,e=+t,i=+n,o=e&r,u=i&r,c=e>>16,f=i>>16,a=(c*u>>>0)+(o*u>>>16);return c*f+(a>>16)+((o*f>>>0)+(a&r)>>16)}})},function(t,n,r){var e=r(1);e(e.S,"Math",{isubh:function(t,n,r,e){var i=t>>>0,o=n>>>0,u=r>>>0;return o-(e>>>0)-((~i&u|~(i^u)&i-u>>>0)>>>31)|0}})},function(t,n,r){var e=r(1);e(e.S,"Math",{umulh:function(t,n){var r=65535,e=+t,i=+n,o=e&r,u=i&r,c=e>>>16,f=i>>>16,a=(c*u>>>0)+(o*u>>>16);return c*f+(a>>>16)+((o*f>>>0)+(a&r)>>>16)}})},function(t,n,r){"use strict";var e=r(1),i=r(17),o=r(26),u=r(11);r(10)&&e(e.P+r(124),"Object",{__defineGetter__:function(t,n){u.f(i(this),t,{get:o(n),enumerable:!0,configurable:!0})}})},function(t,n,r){"use strict";var e=r(1),i=r(17),o=r(26),u=r(11);r(10)&&e(e.P+r(124),"Object",{__defineSetter__:function(t,n){u.f(i(this),t,{set:o(n),enumerable:!0,configurable:!0})}})},function(t,n,r){var e=r(1),i=r(176)(!0);e(e.S,"Object",{entries:function(t){return i(t)}})},function(t,n,r){var e=r(1),i=r(177),o=r(30),u=r(31),c=r(131);e(e.S,"Object",{getOwnPropertyDescriptors:function(t){for(var n,r=o(t),e=u.f,f=i(r),a={},s=0;f.length>s;)c(a,n=f[s++],e(r,n));return a}})},function(t,n,r){"use strict";var e=r(1),i=r(17),o=r(50),u=r(32),c=r(31).f;r(10)&&e(e.P+r(124),"Object",{__lookupGetter__:function(t){var n,r=i(this),e=o(t,!0);do{if(n=c(r,e))return n.get}while(r=u(r))}})},function(t,n,r){"use strict";var e=r(1),i=r(17),o=r(50),u=r(32),c=r(31).f;r(10)&&e(e.P+r(124),"Object",{__lookupSetter__:function(t){var n,r=i(this),e=o(t,!0);do{if(n=c(r,e))return n.set}while(r=u(r))}})},function(t,n,r){var e=r(1),i=r(176)(!1);e(e.S,"Object",{values:function(t){return i(t)}})},function(t,n,r){"use strict";var e=r(1),i=r(3),o=r(52),u=r(143)(),c=r(7)("observable"),f=r(26),a=r(2),s=r(68),l=r(73),h=r(27),v=r(79),p=v.RETURN,d=function(t){return null==t?void 0:f(t)},y=function(t){var n=t._c;n&&(t._c=void 0,n())},g=function(t){return void 0===t._o},b=function(t){g(t)||(t._o=void 0,y(t))},m=function(t,n){a(t),this._c=void 0,this._o=t,t=new x(this);try{var r=n(t),e=r;null!=r&&("function"==typeof r.unsubscribe?r=function(){e.unsubscribe()}:f(r),this._c=r)}catch(n){return void t.error(n)}g(this)&&y(this)};m.prototype=l({},{unsubscribe:function(){b(this)}});var x=function(t){this._s=t};x.prototype=l({},{next:function(t){var n=this._s;if(!g(n)){var r=n._o;try{var e=d(r.next);if(e)return e.call(r,t)}catch(t){try{b(n)}finally{throw t}}}},error:function(t){var n=this._s;if(g(n))throw t;var r=n._o;n._o=void 0;try{var e=d(r.error);if(!e)throw t;t=e.call(r,t)}catch(t){try{y(n)}finally{throw t}}return y(n),t},complete:function(t){var n=this._s;if(!g(n)){var r=n._o;n._o=void 0;try{var e=d(r.complete);t=e?e.call(r,t):void 0}catch(t){try{y(n)}finally{throw t}}return y(n),t}}});var w=function(t){s(this,w,"Observable","_f")._f=f(t)};l(w.prototype,{subscribe:function(t){return new m(t,this._f)},forEach:function(t){var n=this;return new(o.Promise||i.Promise)(function(r,e){f(t);var i=n.subscribe({next:function(n){try{return t(n)}catch(t){e(t),i.unsubscribe()}},error:e,complete:r})})}}),l(w,{from:function(t){var n="function"==typeof this?this:w,r=d(a(t)[c]);if(r){var e=a(r.call(t));return e.constructor===n?e:new n(function(t){return e.subscribe(t)})}return new n(function(n){var r=!1;return u(function(){if(!r){try{if(v(t,!1,function(t){if(n.next(t),r)return p})===p)return}catch(t){if(r)throw t;return void n.error(t)}n.complete()}}),function(){r=!0}})},of:function(){for(var t=0,n=arguments.length,r=Array(n);t<n;)r[t]=arguments[t++];return new("function"==typeof this?this:w)(function(t){var n=!1;return u(function(){if(!n){for(var e=0;e<r.length;++e)if(t.next(r[e]),n)return;t.complete()}}),function(){n=!0}})}}),h(w.prototype,c,function(){return this}),e(e.G,{Observable:w}),r(74)("Observable")},function(t,n,r){var e=r(54),i=r(2),o=e.key,u=e.set;e.exp({defineMetadata:function(t,n,r,e){u(t,n,i(r),o(e))}})},function(t,n,r){var e=r(54),i=r(2),o=e.key,u=e.map,c=e.store;e.exp({deleteMetadata:function(t,n){var r=arguments.length<3?void 0:o(arguments[2]),e=u(i(n),r,!1);if(void 0===e||!e.delete(t))return!1;if(e.size)return!0;var f=c.get(n);return f.delete(r),!!f.size||c.delete(n)}})},function(t,n,r){var e=r(185),i=r(161),o=r(54),u=r(2),c=r(32),f=o.keys,a=o.key,s=function(t,n){var r=f(t,n),o=c(t);if(null===o)return r;var u=s(o,n);return u.length?r.length?i(new e(r.concat(u))):u:r};o.exp({getMetadataKeys:function(t){return s(u(t),arguments.length<2?void 0:a(arguments[1]))}})},function(t,n,r){var e=r(54),i=r(2),o=r(32),u=e.has,c=e.get,f=e.key,a=function(t,n,r){if(u(t,n,r))return c(t,n,r);var e=o(n);return null!==e?a(t,e,r):void 0};e.exp({getMetadata:function(t,n){return a(t,i(n),arguments.length<3?void 0:f(arguments[2]))}})},function(t,n,r){var e=r(54),i=r(2),o=e.keys,u=e.key;e.exp({getOwnMetadataKeys:function(t){
return o(i(t),arguments.length<2?void 0:u(arguments[1]))}})},function(t,n,r){var e=r(54),i=r(2),o=e.get,u=e.key;e.exp({getOwnMetadata:function(t,n){return o(t,i(n),arguments.length<3?void 0:u(arguments[2]))}})},function(t,n,r){var e=r(54),i=r(2),o=r(32),u=e.has,c=e.key,f=function(t,n,r){if(u(t,n,r))return!0;var e=o(n);return null!==e&&f(t,e,r)};e.exp({hasMetadata:function(t,n){return f(t,i(n),arguments.length<3?void 0:c(arguments[2]))}})},function(t,n,r){var e=r(54),i=r(2),o=e.has,u=e.key;e.exp({hasOwnMetadata:function(t,n){return o(t,i(n),arguments.length<3?void 0:u(arguments[2]))}})},function(t,n,r){var e=r(54),i=r(2),o=r(26),u=e.key,c=e.set;e.exp({metadata:function(t,n){return function(r,e){c(t,n,(void 0!==e?i:o)(r),u(e))}}})},function(t,n,r){var e=r(1);e(e.P+e.R,"Set",{toJSON:r(165)("Set")})},function(t,n,r){"use strict";var e=r(1),i=r(147)(!0);e(e.P,"String",{at:function(t){return i(this,t)}})},function(t,n,r){"use strict";var e=r(1),i=r(46),o=r(16),u=r(122),c=r(120),f=RegExp.prototype,a=function(t,n){this._r=t,this._s=n};r(139)(a,"RegExp String",function(){var t=this._r.exec(this._s);return{value:t,done:null===t}}),e(e.P,"String",{matchAll:function(t){if(i(this),!u(t))throw TypeError(t+" is not a regexp!");var n=String(this),r="flags"in f?String(t.flags):c.call(t),e=new RegExp(t.source,~r.indexOf("g")?r:"g"+r);return e.lastIndex=o(t.lastIndex),new a(e,n)}})},function(t,n,r){"use strict";var e=r(1),i=r(181);e(e.P,"String",{padEnd:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0,!1)}})},function(t,n,r){"use strict";var e=r(1),i=r(181);e(e.P,"String",{padStart:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0,!0)}})},function(t,n,r){"use strict";r(82)("trimLeft",function(t){return function(){return t(this,1)}},"trimStart")},function(t,n,r){"use strict";r(82)("trimRight",function(t){return function(){return t(this,2)}},"trimEnd")},function(t,n,r){r(153)("asyncIterator")},function(t,n,r){r(153)("observable")},function(t,n,r){var e=r(1);e(e.S,"System",{global:r(3)})},function(t,n,r){for(var e=r(155),i=r(28),o=r(3),u=r(27),c=r(80),f=r(7),a=f("iterator"),s=f("toStringTag"),l=c.Array,h=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],v=0;v<5;v++){var p,d=h[v],y=o[d],g=y&&y.prototype;if(g){g[a]||u(g,a,l),g[s]||u(g,s,d),c[d]=l;for(p in e)g[p]||i(g,p,e[p],!0)}}},function(t,n,r){var e=r(1),i=r(151);e(e.G+e.B,{setImmediate:i.set,clearImmediate:i.clear})},function(t,n,r){var e=r(3),i=r(1),o=r(121),u=r(207),c=e.navigator,f=!!c&&/MSIE .\./.test(c.userAgent),a=function(t){return f?function(n,r){return t(o(u,[].slice.call(arguments,2),"function"==typeof n?n:Function(n)),r)}:t};i(i.G+i.B+i.F*f,{setTimeout:a(e.setTimeout),setInterval:a(e.setInterval)})},function(t,n,r){r(330),r(269),r(271),r(270),r(273),r(275),r(280),r(274),r(272),r(282),r(281),r(277),r(278),r(276),r(268),r(279),r(283),r(284),r(236),r(238),r(237),r(286),r(285),r(256),r(266),r(267),r(257),r(258),r(259),r(260),r(261),r(262),r(263),r(264),r(265),r(239),r(240),r(241),r(242),r(243),r(244),r(245),r(246),r(247),r(248),r(249),r(250),r(251),r(252),r(253),r(254),r(255),r(317),r(322),r(329),r(320),r(312),r(313),r(318),r(323),r(325),r(308),r(309),r(310),r(311),r(314),r(315),r(316),r(319),r(321),r(324),r(326),r(327),r(328),r(231),r(233),r(232),r(235),r(234),r(220),r(218),r(224),r(221),r(227),r(229),r(217),r(223),r(214),r(228),r(212),r(226),r(225),r(219),r(222),r(211),r(213),r(216),r(215),r(230),r(155),r(302),r(307),r(184),r(303),r(304),r(305),r(306),r(287),r(183),r(185),r(186),r(342),r(331),r(332),r(337),r(340),r(341),r(335),r(338),r(336),r(339),r(333),r(334),r(288),r(289),r(290),r(291),r(292),r(295),r(293),r(294),r(296),r(297),r(298),r(299),r(301),r(300),r(343),r(369),r(372),r(371),r(373),r(374),r(370),r(375),r(376),r(354),r(357),r(353),r(351),r(352),r(355),r(356),r(346),r(368),r(377),r(345),r(347),r(349),r(348),r(350),r(359),r(360),r(362),r(361),r(364),r(363),r(365),r(366),r(367),r(344),r(358),r(380),r(379),r(378),t.exports=r(52)},function(t,n){function r(t,n){if("string"==typeof n)return t.insertAdjacentHTML("afterend",n);var r=t.nextSibling;return r?t.parentNode.insertBefore(n,r):t.parentNode.appendChild(n)}t.exports=r},,,,,,,,,function(t,n,r){(function(n,r){!function(n){"use strict";function e(t,n,r,e){var i=n&&n.prototype instanceof o?n:o,u=Object.create(i.prototype),c=new p(e||[]);return u._invoke=s(t,r,c),u}function i(t,n,r){try{return{type:"normal",arg:t.call(n,r)}}catch(t){return{type:"throw",arg:t}}}function o(){}function u(){}function c(){}function f(t){["next","throw","return"].forEach(function(n){t[n]=function(t){return this._invoke(n,t)}})}function a(t){function n(r,e,o,u){var c=i(t[r],t,e);if("throw"!==c.type){var f=c.arg,a=f.value;return a&&"object"==typeof a&&m.call(a,"__await")?Promise.resolve(a.__await).then(function(t){n("next",t,o,u)},function(t){n("throw",t,o,u)}):Promise.resolve(a).then(function(t){f.value=t,o(f)},u)}u(c.arg)}function e(t,r){function e(){return new Promise(function(e,i){n(t,r,e,i)})}return o=o?o.then(e,e):e()}"object"==typeof r&&r.domain&&(n=r.domain.bind(n));var o;this._invoke=e}function s(t,n,r){var e=P;return function(o,u){if(e===F)throw new Error("Generator is already running");if(e===M){if("throw"===o)throw u;return y()}for(r.method=o,r.arg=u;;){var c=r.delegate;if(c){var f=l(c,r);if(f){if(f===A)continue;return f}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(e===P)throw e=M,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);e=F;var a=i(t,n,r);if("normal"===a.type){if(e=r.done?M:j,a.arg===A)continue;return{value:a.arg,done:r.done}}"throw"===a.type&&(e=M,r.method="throw",r.arg=a.arg)}}}function l(t,n){var r=t.iterator[n.method];if(r===g){if(n.delegate=null,"throw"===n.method){if(t.iterator.return&&(n.method="return",n.arg=g,l(t,n),"throw"===n.method))return A;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return A}var e=i(r,t.iterator,n.arg);if("throw"===e.type)return n.method="throw",n.arg=e.arg,n.delegate=null,A;var o=e.arg;return o?o.done?(n[t.resultName]=o.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=g),n.delegate=null,A):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,A)}function h(t){var n={tryLoc:t[0]};1 in t&&(n.catchLoc=t[1]),2 in t&&(n.finallyLoc=t[2],n.afterLoc=t[3]),this.tryEntries.push(n)}function v(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function p(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(h,this),this.reset(!0)}function d(t){if(t){var n=t[w];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,e=function n(){for(;++r<t.length;)if(m.call(t,r))return n.value=t[r],n.done=!1,n;return n.value=g,n.done=!0,n};return e.next=e}}return{next:y}}function y(){return{value:g,done:!0}}var g,b=Object.prototype,m=b.hasOwnProperty,x="function"==typeof Symbol?Symbol:{},w=x.iterator||"@@iterator",S=x.asyncIterator||"@@asyncIterator",_=x.toStringTag||"@@toStringTag",O="object"==typeof t,E=n.regeneratorRuntime;if(E)return void(O&&(t.exports=E));E=n.regeneratorRuntime=O?t.exports:{},E.wrap=e;var P="suspendedStart",j="suspendedYield",F="executing",M="completed",A={},N={};N[w]=function(){return this};var T=Object.getPrototypeOf,I=T&&T(T(d([])));I&&I!==b&&m.call(I,w)&&(N=I);var k=c.prototype=o.prototype=Object.create(N);u.prototype=k.constructor=c,c.constructor=u,c[_]=u.displayName="GeneratorFunction",E.isGeneratorFunction=function(t){var n="function"==typeof t&&t.constructor;return!!n&&(n===u||"GeneratorFunction"===(n.displayName||n.name))},E.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,_ in t||(t[_]="GeneratorFunction")),t.prototype=Object.create(k),t},E.awrap=function(t){return{__await:t}},f(a.prototype),a.prototype[S]=function(){return this},E.AsyncIterator=a,E.async=function(t,n,r,i){var o=new a(e(t,n,r,i));return E.isGeneratorFunction(n)?o:o.next().then(function(t){return t.done?t.value:o.next()})},f(k),k[_]="Generator",k.toString=function(){return"[object Generator]"},E.keys=function(t){var n=[];for(var r in t)n.push(r);return n.reverse(),function r(){for(;n.length;){var e=n.pop();if(e in t)return r.value=e,r.done=!1,r}return r.done=!0,r}},E.values=d,p.prototype={constructor:p,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=g,this.done=!1,this.delegate=null,this.method="next",this.arg=g,this.tryEntries.forEach(v),!t)for(var n in this)"t"===n.charAt(0)&&m.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=g)},stop:function(){this.done=!0;var t=this.tryEntries[0],n=t.completion;if("throw"===n.type)throw n.arg;return this.rval},dispatchException:function(t){function n(n,e){return o.type="throw",o.arg=t,r.next=n,e&&(r.method="next",r.arg=g),!!e}if(this.done)throw t;for(var r=this,e=this.tryEntries.length-1;e>=0;--e){var i=this.tryEntries[e],o=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=m.call(i,"catchLoc"),c=m.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,n){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc<=this.prev&&m.call(e,"finallyLoc")&&this.prev<e.finallyLoc){var i=e;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=n&&n<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=n,i?(this.method="next",this.next=i.finallyLoc,A):this.complete(o)},complete:function(t,n){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&n&&(this.next=n),A},finish:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),v(r),A}},catch:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc===t){var e=r.completion;if("throw"===e.type){var i=e.arg;v(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:d(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=g),A}}}("object"==typeof n?n:"object"==typeof window?window:"object"==typeof self?self:this)}).call(n,function(){return this}(),r(158))}])</script><script src="/./main.0cf68a.js"></script><script>!function(){!function(e){var t=document.createElement("script");document.getElementsByTagName("body")[0].appendChild(t),t.setAttribute("src",e)}("/slider.e37972.js")}()</script>


    
<div class="tools-col" q-class="show:isShow,hide:isShow|isFalse" q-on="click:stop(e)">
  <div class="tools-nav header-menu">
    
    
      
      
      
    
      
      
      
    
    

    <ul style="width: 70%">
    
    
      
      <li style="width: 50%" q-on="click: openSlider(e, 'innerArchive')"><a href="javascript:void(0)" q-class="active:innerArchive">所有文章</a></li>
      
        
      
      <li style="width: 50%" q-on="click: openSlider(e, 'aboutme')"><a href="javascript:void(0)" q-class="active:aboutme">关于我</a></li>
      
        
    </ul>
  </div>
  <div class="tools-wrap">
    
    	<section class="tools-section tools-section-all" q-show="innerArchive">
        <div class="search-wrap">
          <input class="search-ipt" q-model="search" type="text" placeholder="find something…">
          <i class="icon-search icon" q-show="search|isEmptyStr"></i>
          <i class="icon-close icon" q-show="search|isNotEmptyStr" q-on="click:clearChose(e)"></i>
        </div>
        <div class="widget tagcloud search-tag">
          <p class="search-tag-wording">tag:</p>
          <label class="search-switch">
            <input type="checkbox" q-on="click:toggleTag(e)" q-attr="checked:showTags">
          </label>
          <ul class="article-tag-list" q-show="showTags">
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color3">前端</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color3">技能</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color4">数据库</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color3">工具</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color5">消息队列</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color3">项目</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color5">Spring全家桶</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color1">前后端分离</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color3">随笔</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color4">git</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color5">数据结构</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color5">java</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color4">web</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color3">算法</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color1">易错点系列</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color2">java基础</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color3">project</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color3">自传</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)" class="js-tag color2">面向对象思想</a>
              </li>
            
            <div class="clearfix"></div>
          </ul>
        </div>
        <ul class="search-ul">
          <p q-show="jsonFail" style="padding: 20px; font-size: 12px;">
            缺失模块。<br/>1、请确保node版本大于6.2<br/>2、在博客根目录（注意不是yilia根目录）执行以下命令：<br/> npm i hexo-generator-json-content --save<br/><br/>
            3、在根目录_config.yml里添加配置：
<pre style="font-size: 12px;" q-show="jsonFail">
  jsonContent:
    meta: false
    pages: false
    posts:
      title: true
      date: true
      path: true
      text: false
      raw: false
      content: false
      slug: false
      updated: false
      comments: false
      link: false
      permalink: false
      excerpt: false
      categories: false
      tags: true
</pre>
          </p>
          <li class="search-li" q-repeat="items" q-show="isShow">
            <a q-attr="href:path|urlformat" class="search-title"><i class="icon-quo-left icon"></i><span q-text="title"></span></a>
            <p class="search-time">
              <i class="icon-calendar icon"></i>
              <span q-text="date|dateformat"></span>
            </p>
            <p class="search-tag">
              <i class="icon-price-tags icon"></i>
              <span q-repeat="tags" q-on="click:choseTag(e, name)" q-text="name|tagformat"></span>
            </p>
          </li>
        </ul>
    	</section>
    

    

    
    	<section class="tools-section tools-section-me" q-show="aboutme">
  	  	
  	  		<div class="aboutme-wrap" id="js-aboutme">很惭愧&lt;br&gt;&lt;br&gt;只做了一点微小的工作&lt;br&gt;谢谢大家</div>
  	  	
    	</section>
    
  </div>
  
</div>
    <!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                      <div class="pswp__preloader__cut">
                        <div class="pswp__preloader__donut"></div>
                      </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div> 
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>
  </div>
</body>
</html>